G4P Textfield Object does not respond to ENTERED events
in
Contributed Library Questions
•
2 years ago
I am trying to create a basic textfield object to capture text entered by a user. I tried out the textfield example on the G4P main page and discovered that it doesn't respond to the enter key at all. Below is a code snippet based on that example that demonstrates the different events that are associated with textfields. Notice that the "ENTERED" event is never activated. Is there an alternate way of responding to the enter key in G4P? Does this code work for other people? Any help is appreciated.
Cheers,
Aaron
- import guicomponents.*;
- GTextField textField;
- void setup(){
- background(0);
- size(350, 780);
- textField = new GTextField(this, "Status", 100, 30, 150, 20, true);
- }
- void draw(){
- }
- void handleTextFieldEvents(GTextField tfield){
- String event = "";
- if(tfield == textField){
- switch (tfield.getEventType()){
- case GTextField.ENTERED:
- println("Entered");
- break;
- case GTextField.CHANGED:
- println("Changed");
- break;
- case GTextField.SET:
- println("Set");
- break;
- }
- }
- }
1