com.google.gwt.user.client.Event类的使用及代码示例

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

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

Event介绍

[英]An opaque handle to a native DOM Event. An Event cannot be created directly. Instead, use the Event type when returning a native DOM event from JSNI methods. An Event passed back into JSNI becomes the original DOM event the Event was created from, and can be accessed in JavaScript code as expected. This is typically done by calling methods in the com.google.gwt.user.client.DOM class.
[中]本机DOM事件的不透明句柄。无法直接创建Event。相反,当从JSNI方法返回本机DOM事件时,请使用Event类型。传回JSNI的Event成为创建Event的原始DOM事件,可以按预期在JavaScript代码中访问。这通常是通过在com中调用方法来完成的。谷歌。gwt。使用者客户DOM类。

代码示例

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

public void onBrowserEvent(Event event) {
 if (!resettingScrollables && Event.ONSCROLL == event.getTypeInt()) {
  EventTarget eventTarget = event.getEventTarget();
  if (!Element.is(eventTarget)) {
   return;
  }
  Element target = eventTarget.cast();
  if (target == collapsible || target == expandable) {
   handleResize();
  }
 }
}

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

/**
 * This method is called directly by native code when event preview is being
 * used.
 * 
 * @param evt a handle to the event being previewed
 * @return <code>false</code> to cancel the event
 */
public static boolean previewEvent(Event evt) {
 // Fire a NativePreviewEvent to NativePreviewHandlers
 boolean ret = Event.fireNativePreviewEvent(evt);
 // If the preview cancels the event, stop it from bubbling and performing
 // its default action. Check for a null evt to allow unit tests to run.
 if (!ret && evt != null) {
  evt.stopPropagation();
  evt.preventDefault();
 }
 return ret;
}

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

@Deprecated
public static void add(EventPreview listener) {
 Event.addNativePreviewHandler(new NativePreview(listener));
}

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

private void eatEvent(Event event) {
 event.stopPropagation();
 event.preventDefault();
}

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

@Override
public Element eventGetToElement(Event evt) {
 if (evt.getType().equals(BrowserEvents.MOUSEOVER)) {
  return evt.getEventTarget().cast();
 }
 if (evt.getType().equals(BrowserEvents.MOUSEOUT)) {
  return evt.getRelatedEventTarget().cast();
 }
 return null;
}

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

public CustomScrollPanel(Resources resources) {
 super(DOM.createDiv(), DOM.createDiv(), DOM.createDiv());
 containerElem.setClassName(CommonResources.getInlineBlockStyle());
 scrollable.getStyle().setOverflow(Overflow.SCROLL);
 scrollable.appendChild(containerElem);
 scrollableLayer = layout.attachChild(scrollable);
 getElement().getStyle().setOverflow(Overflow.HIDDEN);
 Event.sinkEvents(getElement(), Event.ONSCROLL);
 Event.sinkEvents(getScrollableElement(), Event.ONSCROLL);

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

protected void onBrowserEvent2(Event event) {
 EventTarget eventTarget = event.getEventTarget();
 if (!Element.is(eventTarget)) {
  return;
 final Element target = event.getEventTarget().cast();
  if (TableCellElement.TAG_TD.equalsIgnoreCase(cur.getTagName()) && 
    tableBuilder.isColumn(cur.getFirstChildElement())) {
   cur = cur.getFirstChildElement();
 TableRowElement targetTableRow = targetTableCell.getParentElement().cast();
 String eventType = event.getType();
 boolean isSelect = BrowserEvents.CLICK.equals(eventType)
   || (BrowserEvents.KEYDOWN.equals(eventType) && event.getKeyCode() == KeyCodes.KEY_ENTER);
     int clientX = event.getClientX() + Window.getScrollLeft();
     int clientY = event.getClientY() + Window.getScrollTop();
     int rowLeft = hoveringRow.getAbsoluteLeft();
     int rowTop = hoveringRow.getAbsoluteTop();

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

event.stopPropagation();
   return;
  if (event.getButton() == Event.BUTTON_LEFT) {
   setFocus(true);
   onClickStart();
   DOM.setCapture(getElement());
   isCapturing = true;
   event.preventDefault();
  if (isCapturing) {
   isCapturing = false;
   DOM.releaseCapture(getElement());
   if (isHovering() && event.getButton() == Event.BUTTON_LEFT) {
    onClick();
  if (isCapturing) {
   event.preventDefault();
if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
 char keyCode = (char) event.getKeyCode();
 switch (type) {
  case Event.ONKEYDOWN:

代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit

private void onResizeEvent(Event event) {
  if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
    switch (event.getTypeInt()) {
      case Event.ONMOUSEDOWN:
      case Event.ONTOUCHSTART:
        showResizingCurtain();
        if (BrowserInfo.get().isIE()) {
          resizeBox.getStyle().setVisibility(Style.Visibility.HIDDEN);
        origW = getElement().getOffsetWidth();
        origH = getElement().getOffsetHeight();
        DOM.setCapture(getElement());
        event.preventDefault();
        break;
      case Event.ONMOUSEUP:
        if (resizing) {
          setSize(event);
          event.preventDefault();
        event.preventDefault();
        break;

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

/**
 * Handle an event from a cell. Used by {@link #initEventSystem()}.
 *
 * @param event the event to handle.
 */
private static void handleNonBubblingEvent(Event event) {
 // Get the event target.
 EventTarget eventTarget = event.getEventTarget();
 if (!Element.is(eventTarget)) {
  return;
 }
 Element target = eventTarget.cast();
 // Get the event listener, which is the first widget that handles the
 // specified event type.
 String typeName = event.getType();
 EventListener listener = DOM.getEventListener(target);
 while (target != null && listener == null) {
  target = target.getParentElement().cast();
  if (target != null && isNonBubblingEventHandled(target, typeName)) {
   // The target handles the event, so this must be the event listener.
   listener = DOM.getEventListener(target);
  }
 }
 // Fire the event.
 if (listener != null) {
  DOM.dispatchEvent(event, target, listener);
 }
}

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

@Override
public void onBrowserEvent(Event event) {
 switch (event.getTypeInt()) {
  case Event.ONMOUSEDOWN:
   mouseDown = true;
   int height = Math.max(Window.getClientHeight(),
     Document.get().getScrollHeight());
   glassElem.getStyle().setHeight(height, Unit.PX);
   glassElem.getStyle().setWidth(width, Unit.PX);
   Document.get().getBody().appendChild(glassElem);
   Event.setCapture(getElement());
   event.preventDefault();
   break;
   mouseDown = false;
   glassElem.removeFromParent();
   Event.releaseCapture(getElement());
   event.preventDefault();
   break;
    event.preventDefault();

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

private static void handleNonBubblingEvent(Event event) {
 EventTarget eventTarget = event.getEventTarget();
 if (!Element.is(eventTarget)) {
  return;
 final Element target = eventTarget.cast();
 EventListener listener = DOM.getEventListener(curElem);
 while (curElem != null && listener == null) {
  curElem = curElem.getParentElement();
  listener = (curElem == null) ? null : DOM.getEventListener(curElem);
 String type = event.getType();
 if (BrowserEvents.FOCUSIN.equals(type)) {
  String tagName = target.getTagName().toLowerCase(Locale.ROOT);
  if (inputTypes.contains(tagName)) {
   focusedInput = target;
  dispatchCellEvent(widget, target, Event.ONBLUR, null);
 } else if (BrowserEvents.LOAD.equals(type) || BrowserEvents.ERROR.equals(type)) {
  DOM.dispatchEvent(event, widget.getElement(), listener);

代码示例来源:origin: info.magnolia.ui/magnolia-ui-vaadin-common-widgets

@Override
public void onBrowserEvent(Event event) {
  if (event.getEventTarget().cast() == treeSpacer &&
      treeSpacer.getClassName().contains("node")) {
    if (event.getTypeInt() == Event.ONMOUSEDOWN || event.getTypeInt() == Event.ONTOUCHSTART) {
      sendToggleCollapsedUpdate(getKey());
      event.stopPropagation();
      event.preventDefault();
    }
    return;
  }
  super.onBrowserEvent(event);
}

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

int x = event.getClientX() - senderElem.getAbsoluteLeft()
  + senderElem.getPropertyInt("scrollLeft")
  + Window.getScrollLeft();
int y = event.getClientY() - senderElem.getAbsoluteTop()
  + senderElem.getPropertyInt("scrollTop")
  + Window.getScrollTop();
switch (DOM.eventGetType(event)) {
 case Event.ONMOUSEDOWN:
  fireMouseDown(sender, x, y);
  Element from = DOM.eventGetFromElement(event);
  if (from == null || !senderElem.isOrHasChild(from)) {
   fireMouseEnter(sender);
  Element to = DOM.eventGetToElement(event);
  if (to == null || !senderElem.isOrHasChild(to)) {
   fireMouseLeave(sender);

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

protected void onBrowserEvent2(Event event) {
 EventTarget eventTarget = event.getEventTarget();
 if (!Element.is(eventTarget)) {
  return;
 final Element target = event.getEventTarget().cast();
 while ((cellTarget != null) && ((idxString = cellTarget.getAttribute("__idx")).length() == 0)) {
  cellTarget = cellTarget.getParentElement();
  String eventType = event.getType();
  boolean isClick = BrowserEvents.CLICK.equals(eventType);
  int idx = Integer.parseInt(idxString);

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

@Override
public void onBrowserEvent(Event event) {
 switch (DOM.eventGetType(event)) {
   Element target = DOM.eventGetTarget(event);
   if (splitElem.isOrHasChild(target)) {
    startResizingFrom(event.getClientX() - getAbsoluteLeft(),
      event.getClientY() - getAbsoluteTop());
    DOM.setCapture(getElement());
    event.preventDefault();
   if (isResizing()) {
    assert DOM.getCaptureElement() != null;
    onSplitterResize(event.getClientX() - getAbsoluteLeft(),
      event.getClientY() - getAbsoluteTop());
    event.preventDefault();

代码示例来源:origin: fr.putnami.pwt/pwt

private boolean eventTargetsDropDown(NativePreviewEvent event) {
  Event nativeEvent = Event.as(event.getNativeEvent());
  EventTarget target = nativeEvent.getEventTarget();
  if (Element.is(target)) {
    return this.getElement().isOrHasChild(Element.as(target));
  }
  return false;
}

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

case Event.ONKEYUP:
 if (event.getAltKey() || event.getMetaKey()) {
  super.onBrowserEvent(event);
  return;
 Element e = DOM.eventGetTarget(event);
 if (shouldTreeDelegateFocusToElement(e)) {
 } else if ((curSelection != null) && curSelection.getContentElem().isOrHasChild(e)) {
  setFocus(true);
 if ((DOM.eventGetCurrentTarget(event) == getElement())
   && (event.getButton() == Event.BUTTON_LEFT)) {
  elementClicked(DOM.eventGetTarget(event));
 if (event.getKeyCode() == KeyCodes.KEY_TAB) {
  ArrayList<Element> chain = new ArrayList<Element>();
  collectElementChain(chain, getElement(), DOM.eventGetTarget(event));
case Event.ONKEYDOWN:
case Event.ONKEYUP: {
 if (KeyCodes.isArrowKey(event.getKeyCode())) {
  event.stopPropagation();
  event.preventDefault();
  return;

代码示例来源:origin: com.github.jdramaix/gwtchosen

private void choiceDestroyLinkClick(Event e) {
  e.preventDefault();
  if (!isDisabled) {
    pendingDestroyClick = true;
    Element target = e.getEventTarget().cast();
    choiceDestroy($(target));
  } else {
    e.stopPropagation();
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-web-toolkit

@Override
public boolean onEventPreview(Event event) {
  int type = DOM.eventGetType(event);
  if ((type == Event.ONCLICK || type == Event.ONTOUCHEND)
      && event.getEventTarget() != null) {
    Element target = Element.as(event.getEventTarget());
    if (target.getClassName() != null && target.getClassName().contains(CUBA_NOTIFICATION_MODALITY_CURTAIN)) {
      hide();
      return false;
    }
  }
  if (type == Event.ONKEYDOWN && event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
    if (!getElement().getClassName().contains(TRAY_STYLE)) {
      hide();
      return false;
    }
  }
  return super.onEventPreview(event);
}

相关文章