use of org.loboevolution.html.js.events.MouseEventImpl in project LoboEvolution by LoboEvolution.
the class WindowImpl method initWindowScope.
private void initWindowScope(final Document doc) {
final Scriptable ws = this.getWindowScope();
final JavaScript js = JavaScript.getInstance();
JavaInstantiator jiXhttp = () -> {
HTMLDocumentImpl hd = (HTMLDocumentImpl) doc;
return new XMLHttpRequest(getUaContext(), hd.getDocumentURL(), ws);
};
JavaInstantiator jidomp = () -> new DOMParserImpl(document);
js.defineJsObject(ws, "XMLHttpRequest", XMLHttpRequest.class, jiXhttp);
js.defineJsObject(ws, "DOMParser", DOMParserImpl.class, jidomp);
js.defineJsObject(ws, "XMLSerializer", XMLSerializerImpl.class, XMLSerializerImpl::new);
js.defineJsObject(ws, "XPathResult", XPathResultImpl.class, XPathResultImpl::new);
js.defineJsObject(ws, "MouseEvent", MouseEventImpl.class, MouseEventImpl::new);
js.defineJsObject(ws, "UIEvent", UIEventImpl.class, MouseEventImpl::new);
js.defineJsObject(ws, "Element", Element.class, MouseEventImpl::new);
js.defineJsObject(ws, "Event", EventImpl.class, EventImpl::new);
js.defineJsObject(ws, "Text", TextImpl.class, TextImpl::new);
js.defineJsObject(ws, "Storage", LocalStorage.class, LocalStorage::new);
js.defineElementClass(ws, doc, "Comment", "comment", CommentImpl.class);
js.defineElementClass(ws, doc, "Image", "img", HTMLImageElementImpl.class);
js.defineElementClass(ws, doc, "Script", "script", HTMLScriptElementImpl.class);
js.defineElementClass(ws, doc, "IFrame", "iframe", HTMLIFrameElementImpl.class);
js.defineElementClass(ws, doc, "Option", "option", HTMLOptionElementImpl.class);
js.defineElementClass(ws, doc, "Select", "select", HTMLSelectElementImpl.class);
js.defineElementClass(ws, doc, "Console", "console", ConsoleImpl.class);
js.defineElementClass(ws, doc, "HTMLDivElement", "div", HTMLDivElementImpl.class);
js.defineElementClass(ws, doc, "HTMLElement", "html", HTMLElementImpl.class);
js.defineElementClass(ws, doc, "HTMLDocument", "document", HTMLDocumentImpl.class);
}
use of org.loboevolution.html.js.events.MouseEventImpl in project LoboEvolution by LoboEvolution.
the class HtmlController method onMouseOver.
/**
* <p>onMouseOver.</p>
*
* @param renderable a {@link org.loboevolution.html.renderer.BaseBoundableRenderable} object.
* @param nodeStart a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
* @param limit a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
*/
public void onMouseOver(final BaseBoundableRenderable renderable, final ModelNode nodeStart, final MouseEvent event, final int x, final int y, final ModelNode limit) {
ModelNode node = nodeStart;
while (node != null) {
if (node == limit) {
break;
}
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
uiElement.setMouseOver(true);
final Function f = uiElement.getOnmouseover();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("mouseover", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
Executor.executeFunction(uiElement, f, evt, new Object[0]);
}
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
if (rcontext != null) {
rcontext.onMouseOver(uiElement, event);
}
}
node = node.getParentModelNode();
}
setMouseOnMouseOver(renderable, nodeStart, limit);
}
use of org.loboevolution.html.js.events.MouseEventImpl in project LoboEvolution by LoboEvolution.
the class HtmlController method onDoubleClick.
/**
* <p>onDoubleClick.</p>
*
* @return True to propagate further, false if consumed.
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
*/
public boolean onDoubleClick(ModelNode node, MouseEvent event, int x, int y) {
if (logger.isLoggable(Level.INFO)) {
logger.info("onDoubleClick(): node=" + node + ",class=" + node.getClass().getName());
}
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
final Function f = uiElement.getOndblclick();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("dblclick", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
if (!Executor.executeFunction(uiElement, f, evt, new Object[0])) {
return false;
}
}
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
if (rcontext != null) {
if (!rcontext.onDoubleClick(uiElement, event)) {
return false;
}
}
}
final ModelNode parent = node.getParentModelNode();
if (parent == null) {
return true;
}
return onDoubleClick(parent, event, 0, 0);
}
use of org.loboevolution.html.js.events.MouseEventImpl in project LoboEvolution by LoboEvolution.
the class HtmlController method onMouseDown.
/**
* <p>onMouseDown.</p>
*
* @return True to propagate further, false if consumed.
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
*/
public boolean onMouseDown(ModelNode node, MouseEvent event, int x, int y) {
boolean pass = true;
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
final Function f = uiElement.getOnmousedown();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("mousedown", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
pass = Executor.executeFunction(uiElement, f, evt, new Object[0]);
}
}
if (node instanceof HTMLLinkElementImpl) {
((HTMLLinkElementImpl) node).getCurrentStyle().setOverlayColor("#9090FF80");
return false;
}
if (!pass) {
return false;
}
final ModelNode parent = node.getParentModelNode();
if (parent == null) {
return true;
}
return onMouseDown(parent, event, 0, 0);
}
use of org.loboevolution.html.js.events.MouseEventImpl in project LoboEvolution by LoboEvolution.
the class HtmlController method onMouseOver.
/**
* <p>onMouseOver.</p>
*
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
* @param limit a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
*/
public void onMouseOver(ModelNode node, MouseEvent event, int x, int y, ModelNode limit) {
while (node != null) {
if (node == limit) {
break;
}
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
uiElement.setMouseOver(true);
final Function f = uiElement.getOnmouseover();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("mouseover", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
Executor.executeFunction(uiElement, f, evt, new Object[0]);
}
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
if (rcontext != null) {
rcontext.onMouseOver(uiElement, event);
}
}
node = node.getParentModelNode();
}
}
Aggregations