[Gambas-user] Dynamic menu click event

Doriano Blengino doriano.blengino at ...1909...
Sat Nov 15 21:40:43 CET 2008


Toni ha scritto:
> Hi,
>
> I am new to Gambas and I don't know how to solve a problem regarding 
> setting events for new objects.
> I am creating a dynamic menu, but I don't know how to assign an event 
> handler to it.
> Here 2 examples of what I've tried without succes:
>
> Not working 1:
> [...]
> DIM mnu AS Menu
> mnu = NEW Menu(PopUPTray)
> mnu.Name = "a"
>
> PUBLIC SUB a_Click()
>   Message("You clicked on 'a'")
> END
>   
Correct is:

    mnu = new menu(blablah) AS "menua"

  public sub menua_click()
    ....
  end


The only situation where the event handler name has something to do with 
object name is when you use the GUI designer: if you put a Button1 on 
the form, the event handler name will be Button1_click(). In all the 
other cases (ie, when instantiating from code), you must use the AS 
"xxx" syntax.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list