Recent

Author Topic: Changing and redisplaying a menu  (Read 808 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 7485
Changing and redisplaying a menu
« on: July 27, 2024, 11:13:23 pm »
This revisits something I asked a few years ago (without response), as a direct followon to https://forum.lazarus.freepascal.org/index.php/topic,68030.msg524940.html#msg524940 where @cdbc demonstrates how to close a frame by posting a message.

If a menu has an item which controls whether additional detailed items are displayed, could something similar be used to immediately redisplay the menu, i.e. make it look as though it didn't disappear after the item was clicked?

Two screenshot images appended in explanation (edited to make both appear correctly).

Context: this is from an emulator for an IBM 2741 electromechanical terminal, basically a Selectric on steroids. I added the potential for not just multiple type elements ("golfballs") and keyboards, but different line encodings including 5-bit for RTTY etc. It ended up being very useful indeed, but I've never made the source public since it used the original linkage codes internally which made it hellaceously difficult to maintain particularly when cut-and-pasting terminal output (Unicode) back to the line.

MarkMLl
« Last Edit: July 27, 2024, 11:23:56 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 6523
Re: Changing and redisplaying a menu
« Reply #1 on: July 27, 2024, 11:47:08 pm »
enumerate through the child menus from the top one, when you get the index you want or if you already know the index you can then set the Visible property of the concerned child memuitems based on the selected menu.

 there is a TAG identifier you can use as an indicator etc.

 I believe i've done this before, disabling and not allowing menus to be display based on content and configuration schemes.

 
 
 
The only true wisdom is knowing you know nothing

MarkMLl

  • Hero Member
  • *****
  • Posts: 7485
Re: Changing and redisplaying a menu
« Reply #2 on: July 28, 2024, 12:05:25 am »
enumerate through the child menus from the top one, when you get the index you want or if you already know the index you can then set the Visible property of the concerned child memuitems based on the selected menu.

Yes, I know. That's not what I'm asking.

What I'm asking is if there's a way to make the menu immediately redisplay, rather than its hiding as soon as one of its entries is clicked.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 6523
Re: Changing and redisplaying a menu
« Reply #3 on: July 28, 2024, 03:23:36 am »
I found the widget is not 100% MS compliant but if you assign an accellerator key to the main tree that drops all of that it will
redisplay where you were.

Tested on windows.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.MenuItem2Click(Sender: TObject);  
  2. Const
  3.   KEYEVENTF_KEYDOWN = 0;
  4.   KEYEVENTF_EXTENDEDKEY = 1;
  5.   KEYEVENTF_KEYUP = 2; /
  6. Var
  7.   M:TLMessage;
  8. begin
  9.   MenuItem3.Visible := MenuItem2.checked;
  10.   MenuItem4.Visible := MenuItem2.Checked;
  11.   keybd_event(VK_LMENU, 0, KEYEVENTF_KEYDOWN, 0);
  12.   keybd_event(VK_A, 0, KEYEVENTF_KEYDOWN, 0);
  13.   keybd_event(VK_A, 0, KEYEVENTF_KEYUP, 0);
  14.   keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0);
  15.  
  16. end;                                                
  17.  
  18.  
A +ALT is the key to drop down the menu from the menu bar so that it redisplays after you have modified the list
the menu 3 and 4 here are the test items you are hiding and showing using Menu 2 click evnet.

The only true wisdom is knowing you know nothing

MarkMLl

  • Hero Member
  • *****
  • Posts: 7485
Re: Changing and redisplaying a menu
« Reply #4 on: July 28, 2024, 09:25:15 am »
Thanks, I'll have a play with that when I have time but the potential problem with an accelerator key is that the program already intercepts a potentially-large number of key combinations to support APL etc. characters.

I don't know whther you've come across it but consider /this/ monstrosity...

https://web.archive.org/web/20200216181909/http://www.aplusdev.org/keyboard.html

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018