Search in sources :

Example 1 with HTMLIFrameElement

use of elemental2.dom.HTMLIFrameElement in project gwtproject by treblereel.

the class RichTextAreaImplStandard method hookEvents.

@Override
protected void hookEvents() {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Window wnd = iframe.contentWindow;
    elem.setPropertyObject("__gwt_handler", (DOMImplStandard.Fn) event -> {
        DOM.dispatchEvent(event, elem);
    });
    elem.setPropertyObject("__gwt_focusHandler", (DOMImplStandard.Fn) event -> {
        if (((JsPropertyMap) elem).has("__gwt_isFocused")) {
            return;
        }
        ((JsPropertyMap) elem).set("__gwt_isFocused", true);
        ((DOMImplStandard.Fn) ((JsPropertyMap) elem).get("__gwt_handler")).onInvoke(event);
    });
    elem.setPropertyObject("__gwt_blurHandler", (DOMImplStandard.Fn) event -> {
        if (((JsPropertyMap) elem).has("__gwt_isFocused")) {
            return;
        }
        ((JsPropertyMap) elem).set("__gwt_isFocused", true);
        ((DOMImplStandard.Fn) ((JsPropertyMap) elem).get("__gwt_handler")).onInvoke(event);
    });
    EventListener __gwt_handler = (EventListener) (((JsPropertyMap) elem).get("__gwt_handler"));
    EventListener __gwt_focusHandler = (EventListener) (((JsPropertyMap) elem).get("__gwt_focusHandler"));
    EventListener __gwt_blurHandler = (EventListener) (((JsPropertyMap) elem).get("__gwt_blurHandler"));
    wnd.addEventListener("keydown", __gwt_handler, true);
    wnd.addEventListener("keyup", __gwt_handler, true);
    wnd.addEventListener("keypress", __gwt_handler, true);
    wnd.addEventListener("mousedown", __gwt_handler, true);
    wnd.addEventListener("mouseup", __gwt_handler, true);
    wnd.addEventListener("mousemove", __gwt_handler, true);
    wnd.addEventListener("mouseover", __gwt_handler, true);
    wnd.addEventListener("mouseout", __gwt_handler, true);
    wnd.addEventListener("click", __gwt_handler, true);
    wnd.addEventListener("focus", __gwt_focusHandler, true);
    wnd.addEventListener("blur", __gwt_blurHandler, true);
}
Also used : Window(elemental2.dom.Window) Justification(org.gwtproject.user.client.ui.RichTextArea.Justification) FontSize(org.gwtproject.user.client.ui.RichTextArea.FontSize) Window(elemental2.dom.Window) Element(org.gwtproject.dom.client.Element) SuppressIsSafeHtmlCastCheck(org.gwtproject.safehtml.shared.annotations.SuppressIsSafeHtmlCastCheck) DomGlobal(elemental2.dom.DomGlobal) JsPropertyMap(jsinterop.base.JsPropertyMap) Event(org.gwtproject.user.client.Event) HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) IsSafeHtml(org.gwtproject.safehtml.shared.annotations.IsSafeHtml) DOMImplStandard(org.gwtproject.user.client.impl.DOMImplStandard) EventListener(elemental2.dom.EventListener) RichTextArea(org.gwtproject.user.client.ui.RichTextArea) Document(org.gwtproject.dom.client.Document) IFrameElement(org.gwtproject.dom.client.IFrameElement) Js(jsinterop.base.Js) JsFunction(jsinterop.annotations.JsFunction) DOM(org.gwtproject.user.client.DOM) HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) EventListener(elemental2.dom.EventListener) DOMImplStandard(org.gwtproject.user.client.impl.DOMImplStandard) JsPropertyMap(jsinterop.base.JsPropertyMap)

Example 2 with HTMLIFrameElement

use of elemental2.dom.HTMLIFrameElement in project gwtproject by treblereel.

the class RichTextAreaImplStandard method execCommandAssumingFocus.

void execCommandAssumingFocus(String cmd, String param) {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
    ((ExecCommand) Js.uncheckedCast(Js.asPropertyMap(document).get("execCommand"))).onInvoke(cmd, false, param);
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) Document(org.gwtproject.dom.client.Document)

Example 3 with HTMLIFrameElement

use of elemental2.dom.HTMLIFrameElement in project gwtproject by treblereel.

the class RichTextAreaImplStandard method initElement.

@Override
public void initElement() {
    // Most browsers don"t like setting designMode until slightly _after_
    // the iframe becomes attached to the DOM. Any non-zero timeout will do
    // just fine.
    RichTextAreaImplStandard _this = this;
    _this.onElementInitializing();
    DomGlobal.setTimeout((ignore) -> {
        if (_this.elem != null) {
            HTMLIFrameElement iframe = Js.uncheckedCast(_this.elem);
            if (iframe.contentWindow != null) {
                ((JsPropertyMap) ((JsPropertyMap) iframe.contentWindow).get("document")).set("designMode", "On");
                _this.onElementInitialized();
            }
        }
    }, 1.0D, new Object[0]);
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) JsPropertyMap(jsinterop.base.JsPropertyMap)

Example 4 with HTMLIFrameElement

use of elemental2.dom.HTMLIFrameElement in project gwtproject by treblereel.

the class RichTextAreaImplStandard method queryCommandValueAssumingFocus.

String queryCommandValueAssumingFocus(String cmd) {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
    return ((QueryCommandValue) Js.uncheckedCast(Js.asPropertyMap(document).get("queryCommandValue"))).onInvoke(cmd);
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) Document(org.gwtproject.dom.client.Document)

Example 5 with HTMLIFrameElement

use of elemental2.dom.HTMLIFrameElement in project gwtproject by treblereel.

the class RichTextAreaImplStandard method unhookEvents.

protected void unhookEvents() {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Window wnd = iframe.contentWindow;
    JsPropertyMap asMap = ((JsPropertyMap) iframe);
    wnd.removeEventListener("keydown", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("keyup", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("keypress", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("mousedown", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("mouseup", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("mousemove", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("mouseover", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("mouseout", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("click", (EventListener) asMap.get("__gwt_handler"), true);
    wnd.removeEventListener("focus", (EventListener) asMap.get("__gwt_focusHandler"), true);
    wnd.removeEventListener("blur", (EventListener) asMap.get("__gwt_blurHandler"), true);
    asMap.set("__gwt_handler", null);
    asMap.set("__gwt_focusHandler", null);
    asMap.set("__gwt_blurHandler", null);
}
Also used : Window(elemental2.dom.Window) HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) JsPropertyMap(jsinterop.base.JsPropertyMap)

Aggregations

HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)8 JsPropertyMap (jsinterop.base.JsPropertyMap)4 Document (org.gwtproject.dom.client.Document)4 Window (elemental2.dom.Window)2 DomGlobal (elemental2.dom.DomGlobal)1 EventListener (elemental2.dom.EventListener)1 JsFunction (jsinterop.annotations.JsFunction)1 Js (jsinterop.base.Js)1 Element (org.gwtproject.dom.client.Element)1 IFrameElement (org.gwtproject.dom.client.IFrameElement)1 IsSafeHtml (org.gwtproject.safehtml.shared.annotations.IsSafeHtml)1 SuppressIsSafeHtmlCastCheck (org.gwtproject.safehtml.shared.annotations.SuppressIsSafeHtmlCastCheck)1 DOM (org.gwtproject.user.client.DOM)1 Event (org.gwtproject.user.client.Event)1 DOMImplStandard (org.gwtproject.user.client.impl.DOMImplStandard)1 RichTextArea (org.gwtproject.user.client.ui.RichTextArea)1 FontSize (org.gwtproject.user.client.ui.RichTextArea.FontSize)1 Justification (org.gwtproject.user.client.ui.RichTextArea.Justification)1