[Gambas-devel] gb3 menus and the item that was clicked

Kadaitcha Man nospam.nospam.nospam at ...176...
Thu Dec 31 01:20:25 CET 2009


I have nine (9) popup menus ranging in size from 12 to 40 items, in
total there are about 240 individual child menu items. Looking at the
menu documentation I can see no way to detect what child menu item was
clicked without putting a line of code in the _Click event for each
and every one of the 240 or more items. That means 720+ lines of
additional code.

I might understand the need to write individual lines of code if it
were a truism that all menus always only ever performed distinctly
different functions, but in this case the menu items all do the same
thing, they build a concatenated string based on the text of the
selected item and the context of the popup. That means if I can detect
the child Item that was Clicked then I only need one line of code for
each of the nine popups, or nine lines of code.

Without some way to detect what individual child item was clicked on
the parent menu without interrogating the child itself I am going to
need 720 extra lines of code, three for each item, plus I will have to
comment each and every code segment so it is known what child menu
item the code belongs to, which will take me to 1000 lines of extra
code.

Is there any mechanism that will allow me to detect what child menu
item was selected for a given parent menu?

Are there any other menu-like controls, e.g. the apparently
undocumented MenuButton, that will allow me to interrogate the parent
to see what child was selected?

If the answer to both of those is no, is there any chance that Menu
can be given a new property, called, say, ItemClicked, that directly
references the child that the user clicked on?

In short, I am looking for a mechanism that will allow me to manage
clicked child menu items centrally in one place instead of inside each
child item's _Click event.

Any suggestions and ideas are welcome.




More information about the Devel mailing list