Document doc = ???; HTMLDocument htmlDoc = (HTMLDocument)doc; final HTMLBodyElement body = (HTMLBodyElement)htmlDoc.getBody(); //JS [window] access DOMWindowImpl wnd = (DOMWindowImpl)((DocumentView)htmlDoc).getDefaultView(); //Style access CSSStyleDeclaration style = wnd.getComputedStyle(body, ""); assertEquals("Style extraction", "blue", style.getPropertyValue("background-color"));
private void closeDropDown() { HTMLDocument.current().getBody().removeChild(dropDownElement); HTMLDocument.current().removeEventListener("click", bodyListener); dropDownComponent.destroy(); dropDownElement = null; dropDownComponent = null; }
private void create(int width, int height, @SuppressWarnings("unused") Pixmap.Format format2) { this.width = width; this.height = height; this.format = Format.RGBA8888; canvas = (HTMLCanvasElement) document.createElement("canvas"); canvas.getStyle().setProperty("display", "none"); document.getBody().appendChild(canvas); canvas.setWidth(width); canvas.setHeight(height); context = (CanvasRenderingContext2D) canvas.getContext("2d"); context.setGlobalCompositeOperation("source-over"); id = nextId++; pixmaps.put(id, this); }
private static void showModal(PopupContent content, final AsyncCallback<Void> callback) { final Popup popup = new Popup(Templates.create(content)); popup.wrapper = document.createElement("div"); document.getBody().appendChild(popup.wrapper); popup.component = Templates.bind(popup, popup.wrapper); popup.callback = callback; content.setDelegate(popup::close); } }
@Override public void run(TaskHandler handler) { this.handler = handler; HTMLImageElement image = (HTMLImageElement)window.getDocument().createElement("img"); window.getDocument().getBody().appendChild(image); image.getStyle().setProperty("display", "none"); image.setSrc(path); image.addEventListener("load", this); entry.imageElem = image; } @Override
public TeaVMMusic(TeaVMFileHandle file) { element = (HTMLAudioElement)window.getDocument().createElement("audio"); element.setSrc("assets/" + file.path()); element.addEventListener("ended", (EventListener) evt -> { if (listener != null) { listener.onCompletion(TeaVMMusic.this); } }); window.getDocument().getBody().appendChild(element); }
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); }