[Gambas-user] dynamic popup menu, right click

ron ronstk at ...239...
Thu Mar 30 22:15:10 CEST 2006


On Thursday 30 March 2006 08:54, mike webb wrote:
> has anyone made the right click popup menu work with a dynamicly created 
> menu ??
> 

You can find an very excelent dynamic example in FEditor.class of the IDE 
source code as "Function CreateMenu()" (c) Benoit Minisini :)
around line 369.

Not easy at first view but a lttle study and you see how wel it is made.

The master parent for the Menu is in the main menu bar, set as hidden.
Look with "menu edit"or someting like that on the popup menu when click 
on the form :)

One did make a seperate form for his menu(s). The idea is not so bad
as you can easy use the same menu on different forms/projects.

In brief it look as follow

PRIVATE SUB CreateMenu() 'line 369
  DIM xxx as yyy
  ....
  
  INC Application.Busy
  mnuGoto.Children.Clear

'get data
  cSymbol = CComponent.GetClassSymbols(Name, TRUE)

' filter wanted data
  FOR EACH hSymbol IN cSymbol
    IF LCase(hSymbol.Kind) <> "m" THEN CONTINUE
    IF hSymbol.LineNumber = 0 THEN CONTINUE
    cFunc.Add(hSymbol.Name)
  NEXT

' arrange is
  cFunc.Sort(gb.Text)

  hParent = mnuGoto
  FOR EACH sName IN cFunc
    ...
    hSymbol = cSymbol[sName]
    sFullName = sName
    ...
        hParent = NEW Menu(mnuGoto)
        hParent.Text = sNewParent
    ...
    hMenu = NEW Menu(hParent) AS "mnuGoto"
    hMenu.Text = sName
    hMenu.Tag = hSymbol.LineNumber - 1
    ...
  NEXT
  ...
  mnuGoto.Visible = cFunc.count > 0
  mnuSepGoto.Visible = cFunc.count > 0

  UpdateMenu

  DEC Application.Busy

END



----
Ron




More information about the User mailing list