[Gambas-user] How to return a event from an embedded sub form

Tobias Boege taboege at ...626...
Mon Aug 26 18:06:22 CEST 2013


On Mon, 26 Aug 2013, Marty wrote:
> Hello,
> 
> I need to return a button click from an embedded sub form. I managed to 
> get the sub form embedded in the main form using the code found in the 
> tips that run when Gambas loads.
> 
> The sub form has a button called OK. I want to capture the btnOK_Click 
> event and use it in the main form. I know I can use a global variable 
> that can be seen by both forms but, I'd like to use another method. I've 
> been trying Object.Attach as suggested by Benoit in an email I found on 
> the net. I've not been able to get that working.
> 
> Would you help me with the syntax of Object.Attach or suggest a better 
> approach? I am still learning Gambas syntax so please do not assume 
> anything when sending code examples.
> 

Make your Button on the embedded Form public in the form editor in the IDE.
Let the Button be btnOK and an instance of your embedded Form be
"hEmbedded". Then you can do the following in FMain:

Object.Attach(hEmbedded.btnOK, Me, "btnOK")

This will attach the Button btnOK on the embedded Form to FMain. The Button
gets "btnOK" as its event name and will then raise btnOK_Click() in FMain.

Regards,
Tobi




More information about the User mailing list