Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

[G4P] Trigger a GButton when pressing enter in a textfield

$
0
0

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


Viewing all articles
Browse latest Browse all 2896

Trending Articles