Hello !
I was looking at the library ControlP5 (which implements an interface containing buttons, textfields, checkboxes, etc). I found this piece of code in the example of a textfield :
myTextfield = controlP5.addTextfield("textin", 100, 160, 200, 20);
A few lines later, a custom function is called when the textfield is activated :
public void textin(String theText) { ...
I'm amazed that the function is related to the argument of the constructor. You can actually change it, like passing the String "foo" will call the function foo. Can someone explain me how this is done ?
I was looking at the library ControlP5 (which implements an interface containing buttons, textfields, checkboxes, etc). I found this piece of code in the example of a textfield :
myTextfield = controlP5.addTextfield("textin", 100, 160, 200, 20);
A few lines later, a custom function is called when the textfield is activated :
public void textin(String theText) { ...
I'm amazed that the function is related to the argument of the constructor. You can actually change it, like passing the String "foo" will call the function foo. Can someone explain me how this is done ?
1