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

Toni arosa at ...615...
Thu Dec 31 02:00:46 CET 2009


Hi,
Did you try using "LAST" ?

E.g. Last.Name would give you the name of the last clicked menu.

For instance, if you generate the menus dinamically  I guess that you 
could use the same event firing for all of them (I haven't  tested it, 
but it could go as follows):

  DIM mnu AS Menu
  mnu = NEW Menu(rootmenu) AS "MnuHandler"
  mnu.Name = "mnu1"
  mnu.Caption = "a"
  mnu = NEW Menu(rootmenu) AS "MnuHandler"
  mnu.Name = "mnu2"
  mnu.Caption = "b"

and then

PUBLIC SUB MnuHandler_Click()
    DEBUG Last.Name
END

Regards,


En/na Kadaitcha Man ha escrit:
> 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.
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> Gambas-devel mailing list
> Gambas-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-devel
>   





More information about the Devel mailing list