We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
My question is simple but I don't know how to do it, sorry for my poor English.
How to trigger a GButton if I press Entered key when the Focus is set on a textfield?
The only way how I solve this, is copy the code (MY CODE) in "button1_click1" to "textfield_change1" like this:
public void button1_click1(GButton source, GEvent event) { //_CODE_:button:763418:
//MY CODE
} //_CODE_:button:763418:
public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:textfield_main:267071:
if(event == GEvent.ENTERED){
//MY CODE
}
} //_CODE_:textfield_main:267071:
But, copy and paste the same code repeateadly on all textfields and buttons wich I need to do this is a ugly way to do this.
Any ideas?
Thanks
Answers
The answer is simple, create a method in the main sketch tab to hold the code you want to edit e.g.
Then in the gui tab call this method in the event handlers
Thank you very much @quark, and congrats for your great work in this community. We use G4P a lot.
The reference that you make for your libraries are very helpful. This is the first time I had to ask in the forum :D
Thanks again, regards.
Glad you find G4P useful :)