com.google.gwt.dom.client.Element.dispatchEvent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.google.gwt.dom.client.Element.dispatchEvent()方法的一些代码示例,展示了Element.dispatchEvent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.dispatchEvent()方法的具体详情如下:
包路径:com.google.gwt.dom.client.Element
类名称:Element
方法名:dispatchEvent

Element.dispatchEvent介绍

[英]Dispatched the given event with this element as its target. The event will go through all phases of the browser's normal event dispatch mechanism. Note: Because the browser's normal dispatch mechanism is used, exceptions thrown from within handlers triggered by this method cannot be caught by wrapping this method in a try/catch block. Such exceptions will be caught by the com.google.gwt.core.client.GWT#setUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler)as usual.
[中]已将此元素作为其目标调度给定事件。事件将经历浏览器正常事件分派机制的所有阶段。注意:由于使用浏览器的正常分派机制,因此无法通过将此方法包装在try/catch块中来捕获从此方法触发的处理程序中引发的异常。此类异常将被com捕获。谷歌。gwt。果心客户GWT#setUncaughtExceptionHandler(com.google.GWT.core.client.GWT.UncaughtExceptionHandler)与往常一样。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

private static void triggerScrollEvent(Element elem) {
 elem.dispatchEvent(Document.get().createScrollEvent());
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Dispatch an event to the cell, ensuring that the widget will catch it.
 *
 * @param widget the widget that will handle the event
 * @param target the cell element
 * @param eventBits the event bits to sink
 * @param event the event to fire, or null not to fire an event
 */
private static void dispatchCellEvent(Widget widget, Element target,
  int eventBits, Event event) {
 // Make sure that the target is still a child of the widget. We defer the
 // firing of some events, so its possible that the DOM structure has
 // changed before we fire the event.
 if (!widget.getElement().isOrHasChild(target)) {
  return;
 }
 // Temporary listen for events from the cell. The event listener will be
 // removed in onBrowserEvent().
 DOM.setEventListener(target, widget);
 DOM.sinkEvents(target, eventBits | DOM.getEventsSunk(target));
 // Dispatch the event to the cell.
 if (event != null) {
  target.dispatchEvent(event);
 }
}

代码示例来源:origin: com.allen-sauer.gwt.dnd/gwt-dnd

@Override
 public void execute() {
  // TODO determine if we need to set additional event properties
  elem.dispatchEvent(DOMUtil.createTouchEndEvent(bubbles,
    cancelable,
    detail,
    ctrlKey,
    altKey,
    shiftKey,
    metaKey,
    changedTouches));
 }
});

代码示例来源:origin: com.allen-sauer.gwt.dnd/gwt-dnd

@Override
 public void execute() {
  // TODO determine if we need to set additional event properties
  elem.dispatchEvent(Document.get().createMouseUpEvent(detail,
    screenX,
    screenY,
    clientX,
    clientY,
    ctrlKey,
    altKey,
    shiftKey,
    metaKey,
    button));
 }
});

代码示例来源:origin: net.wetheinter/gwt-user

private static void triggerScrollEvent(Element elem) {
 elem.dispatchEvent(Document.get().createScrollEvent());
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

private static void triggerScrollEvent(Element elem) {
 elem.dispatchEvent(Document.get().createScrollEvent());
}

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

@PatchMethod
static void dispatchEvent(Object domImpl, Element target, NativeEvent evt) {
  EventListener listener = DOM.getEventListener(target);
  if (listener != null && evt instanceof Event) {
    listener.onBrowserEvent((Event) evt);
  }
  // dispatch to parent if needed
  boolean propagationStopped = JavaScriptObjects.getBoolean(evt, JsoProperties.EVENT_IS_STOPPED);
  if (target.getParentElement() != null && propagationStopped) {
    target.getParentElement().dispatchEvent(evt);
  }
}

代码示例来源:origin: gwt-test-utils/gwt-test-utils

@PatchMethod
static void dispatchEvent(Object domImpl, Element target, NativeEvent evt) {
  EventListener listener = DOM.getEventListener(target);
  if (listener != null && evt instanceof Event) {
    listener.onBrowserEvent((Event) evt);
  }
  // dispatch to parent if needed
  boolean propagationStopped = JavaScriptObjects.getBoolean(evt, JsoProperties.EVENT_IS_STOPPED);
  if (target.getParentElement() != null && propagationStopped) {
    target.getParentElement().dispatchEvent(evt);
  }
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Dispatch an event to the cell, ensuring that the widget will catch it.
 *
 * @param widget the widget that will handle the event
 * @param target the cell element
 * @param eventBits the event bits to sink
 * @param event the event to fire, or null not to fire an event
 */
private static void dispatchCellEvent(Widget widget, Element target,
  int eventBits, Event event) {
 // Make sure that the target is still a child of the widget. We defer the
 // firing of some events, so its possible that the DOM structure has
 // changed before we fire the event.
 if (!widget.getElement().isOrHasChild(target)) {
  return;
 }
 // Temporary listen for events from the cell. The event listener will be
 // removed in onBrowserEvent().
 DOM.setEventListener(target, widget);
 DOM.sinkEvents(target, eventBits | DOM.getEventsSunk(target));
 // Dispatch the event to the cell.
 if (event != null) {
  target.dispatchEvent(event);
 }
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Dispatch an event to the cell, ensuring that the widget will catch it.
 *
 * @param widget the widget that will handle the event
 * @param target the cell element
 * @param eventBits the event bits to sink
 * @param event the event to fire, or null not to fire an event
 */
private static void dispatchCellEvent(Widget widget, Element target,
  int eventBits, Event event) {
 // Make sure that the target is still a child of the widget. We defer the
 // firing of some events, so its possible that the DOM structure has
 // changed before we fire the event.
 if (!widget.getElement().isOrHasChild(target)) {
  return;
 }
 // Temporary listen for events from the cell. The event listener will be
 // removed in onBrowserEvent().
 DOM.setEventListener(target, widget);
 DOM.sinkEvents(target, eventBits | DOM.getEventsSunk(target));
 // Dispatch the event to the cell.
 if (event != null) {
  target.dispatchEvent(event);
 }
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

public void dispatchEvent(NativeEvent evt, Object[] datas, Function... funcs) {
 for (Element e : elements()) {
  if (isEventCapable(e)) {
   $(e).data(EventsListener.EVENT_DATA, datas);
   // Ie6-8 don't dispatch bitless event
   if ((browser.ie6 || browser.ie8) && Event.getTypeInt(evt.getType()) == -1) {
    bubbleEventForIE(e, evt.<Event> cast());
   } else {
    e.dispatchEvent(evt);
   }
   if (!JsUtils.isDefaultPrevented(evt)) {
    callHandlers(e, evt, funcs);
   }
   $(e).removeData(EventsListener.EVENT_DATA);
  }
 }
}

相关文章

微信公众号

最新文章

更多

Element类方法