Event Handlers
Elemento provides methods to easily register event handlers. There are constants for most of the known event types. You can either add event handlers when building the element hierarchy:
import static org.jboss.elemento.Elements.*;
import static org.jboss.elemento.EventType.*;
import static org.jboss.elemento.InputType.checkbox;
import static org.jboss.elemento.InputType.text;
HTMLLIElement listItem = li()
.add(div().css("view")
.add(input(checkbox)
.css("toggle")
.on(change, event -> toggle()))
.add(label()
.text("Taste Elemento")
.on(dblclick, event -> edit()))
.add(button()
.css("destroy")
.on(click, event -> destroy())))
.add(input(text)
.css("edit")
.on(keydown, this::keyDown)
.on(blur, event -> blur()))
.element();or register them later using EventType.bind():
The latter approach returns org.gwtproject.event.shared.HandlerRegistration which you can use to remove the handler again.
To make it easier to work with keyboard events, Elemento provides an enum with the most common keyboard codes:
Last updated