[Gambas-user] Dynamic menu click event

Toni arosa at ...2015...
Sat Nov 15 22:15:16 CET 2008


Hi Doriano, thanks for your answer!
I have a related doubt...
If I instantiate some Menu objects from code and I assign them all to 
the same "handling function", is there a way, inside this function, to 
know which Menu object was the one that fired the event?

Regards,
Toni Rosa 

En/na Doriano Blengino ha escrit:
> 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,
>
>   




More information about the User mailing list