how to detect which menu item was clicked
Posted
#1
(In Topic #1262)
Regular

I have a project with many menu items and would like to store the last menu item clicked, or the last form opened via the menu system.
Posted
Administrator

Posted
Regular

Code (gambas)
- .Caption = "Menu1"
- .Caption = "Menu2"
- .Caption = "Menu3"
- .Caption = "Menu4"
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Regular

Thank you both, this works fine.
Posted
Enthusiast

Posted
Administrator

bill-lancaster said
I guess the only way to generate a general menu event is by creating the menu items from code.
Thank you both, this works fine.
Also works when using the menu GUI to create menus.
Posted
Guru

bill-lancaster said
I guess the only way to generate a general menu event is by creating the menu items from code.
Thank you both, this works fine.
No you can use the IDE menu editor. You just make all the menus the same "Group" then the group name becomes the event name for all of them.
Posted
Guru

Got2BeFree said
You can use "Last.xxxx". xxxx = "Name", "Group", "Caption", "Tag". I don't know if "Action" would work as I've never used that when creating menus.
To explain the Action property a bit…..
If you use an action name , say "MyAction" you can then do various things, depending on your needs.
Like grouping objects together, for example a bunch of controls all related to something that might want disabling easily.
You could then do the following if you have a bunch of controls with the Action set to MyAction…
Action["MyAction"].Enabled = False
That would make all MyAction items disabled.
see /comp/gb.qt4/action - Gambas Documentation for other settable action properties
To use the Action property in a similar way to the above Group/Shared event use you must use the Action_Activate(Name As String) event in your form. (although I don't think this is what the OP wants it's good to know)
For example..
That way all objects with MyAction action set will use the same code.
There's a few other reasons tat Action comes in handy, mostly i use it do disable/enable various things that don't have the same parent.
Hope that helps
Posted
Regular

Thanks for the many reponses.
Bill
1 guest and 0 members have just viewed this.

