Navigation
Synopsis Interactive text entry field.
Function
  1. Figure textfield(str text, void (str) scallback, FProperty props...)
  2. Figure textfield(str text, void (str) scallback, bool (str) validate, FProperty props...)
Description A textfield in which the user can enter text:
  1. The callback scallback is called whenever the user types ENTER or RETURN in the textfield.
  2. The callback validate is called for every character that the user types. When validate yields false a visual cue is given that the entered text is erroneous. Only when validate returns true and the user types ENTER or RETURN, scallback will be called.
Examples
public Figure tfield(){
  str entered = "";
  return vcat([ box(textfield("", void(str s){ entered = s;}, fillColor("yellow")), fillColor("yellow")),
                text(str(){return "entered: <entered>";}, left())
              ]);
}  
render(tfield()); 
t1
Pitfalls Unfortunately we cannot show an interactive version of the above example here. Try it out in Rascal itself.

Due to limitations in SWT this does not behave correctly when being placed over or under figures, so do not use them in overlay or mouseOver.
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.