I try to code a TexField that fire an event (a search) on every key press.
But the event should have a debounce option so that it triggers only after a given time without pressing a key.
I follow this documention: https://vaadin.com/docs/v13/flow/creating-components/tutorial-component-events.html
But I struggle to understand how to add the @DebouceEvent to my TextField...
The event:
@DomEvent(value = "input",
debounce = @DebounceSettings(
timeout = 250,
phases = DebouncePhase.TRAILING))
public class InputEvent extends ComponentEvent<TextField> {
private String value;
public InputEvent(TextField source, boolean fromClient,
@EventData("element.value") String value) {
super(source, fromClient);
this.value = value;
}
public String getValue() {
return value;
}
}
The TextField:
TextField searchField= new TextField("my search");
I tried:
searchField.addInputListener(new InputEvent(searchField, true, "input"));
erro:
Error:(41, 38) java: incompatible types: nc.unc.importparcoursup.view.AdmisDetailView.InputEvent cannot be converted to com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.InputEvent>