private void hookEvents() { HTMLDocument document = canvas.getOwnerDocument(); canvas.addEventListener("mousedown", this, true); document.addEventListener("mousedown", this, true); canvas.addEventListener("mouseup", this, true); document.addEventListener("mouseup", this, true); canvas.addEventListener("mousemove", this, true); document.addEventListener("mousemove", this, true); canvas.addEventListener("mousewheel", this, true); document.addEventListener("keydown", this, false); document.addEventListener("keyup", this, false); document.addEventListener("keypress", this, false); canvas.addEventListener("touchstart", this); canvas.addEventListener("touchmove", this); canvas.addEventListener("touchcancel", this); canvas.addEventListener("touchend", this); }
public void dropDown() { if (dropDownElement != null) { return; } dropDownElement = HTMLDocument.current().createElement("div"); dropDownElement.setAttribute("class", "flavour-dropdown flavour-dropdown-calendar"); TextRectangle windowRect = HTMLDocument.current().getBody().getBoundingClientRect(); TextRectangle inputRect = target.getElement().getBoundingClientRect(); dropDownElement.getStyle().setProperty("right", windowRect.getWidth() - inputRect.getRight() + "px"); dropDownElement.getStyle().setProperty("top", inputRect.getBottom() + "px"); CalendarDropDown dropDown = new CalendarDropDown(this::parseValue, newValue -> { closeDropDown(); target.updateValue(cachedFormatObject.format(newValue)); }); dropDownComponent = Templates.bind(dropDown, dropDownElement); HTMLDocument.current().getBody().appendChild(dropDownElement); Window.setTimeout(() -> HTMLDocument.current().addEventListener("click", bodyListener), 0); }