org.uqbar.arena.filters.TextFilter allows to intercept user input from a textbox component.
Interface defines a single message:
/** * Returns false if you want to forbid the user's action. */ public boolean accept(TextInputEvent event);
Note: When you bind a Date property into a Textbox, binder throws an exception if input is incorrect. Filter goes a step beyond, incorrect input does not appear in the textbox component.
class DateTextFilter implements TextFilter { override accept(TextInputEvent event) { val expected = new ArrayList(#["\\d", "\\d?", "/", "\\d", "\\d?", "/", "\\d{0,4}"]) val regex = expected.reverse.fold("")[result, element| '''(«element»«result»)?'''] event.potentialTextResult.matches(regex) } }