Java Code Examples for com.google.gwt.user.client.Event#as()

The following examples show how to use com.google.gwt.user.client.Event#as() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VSliderPanel.java    From vaadin-sliderpanel with MIT License 6 votes vote down vote up
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
    if (autoCollapseSlider && event != null && !event.isCanceled() && expand) {
        Event nativeEvent = Event.as(event.getNativeEvent());

        switch (nativeEvent.getTypeInt()) {
            case Event.ONMOUSEDOWN:
            case Event.ONTOUCHSTART:
            case Event.ONDBLCLICK:

                if (eventTargetsPopup(nativeEvent)) {
                    return;
                }
                if (eventTargetsInnerElementsPopover(nativeEvent)) {
                    return;
                }
                setExpand(false, true);
        }
    }
}
 
Example 2
Source File: CubaFileUploadProgressWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    if (dragging) {
        Event e = Event.as(event.getNativeEvent());
        onDragEvent(e);
        event.cancel();
    }
}
 
Example 3
Source File: SimpleDropdown.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: CompositeFocusHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean eventTargetsContainerOrPartner(NativePreviewEvent event) {
	Event nativeEvent = Event.as(event.getNativeEvent());
	EventTarget target = nativeEvent.getEventTarget();
	if (Element.is(target)) {
		return this.isOrHasChildOfContainerOrPartner(Element.as(target));
	}
	return false;
}
 
Example 5
Source File: InputBoolean.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean eventTargetsLabelOrChild(DomEvent<?> event) {
	Event nativeEvent = Event.as(event.getNativeEvent());
	EventTarget target = nativeEvent.getEventTarget();
	if (Element.is(target)) {
		return this.labelElement.isOrHasChild(Element.as(target));
	}
	return false;
}
 
Example 6
Source File: CubaTooltip.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected void handleShowHide(DomEvent domEvent, boolean isFocused) {
    // CAUTION copied from parent with changes
    Event event = Event.as(domEvent.getNativeEvent());
    Element element = Element.as(event.getEventTarget());

    // We can ignore move event if it's handled by move or over already
    if (currentElement == element && handledByFocus) {
        return;
    }

    // If the parent (sub)component already has a tooltip open and it
    // hasn't changed, we ignore the event.
    // TooltipInfo contains a reference to the parent component that is
    // checked in it's equals-method.
    if (currentElement != null && isTooltipOpen()) {
        TooltipInfo currentTooltip = getTooltipFor(currentElement);
        TooltipInfo newTooltip = getTooltipFor(element);
        if (currentTooltip != null && currentTooltip.equals(newTooltip)) {
            return;
        }
    }

    TooltipInfo info = getTooltipFor(element);
    if (info == null) {
        handleHideEvent();
        currentConnector = null;
    } else {
        boolean elementIsIndicator = elementIsIndicator(element);

        if (closing) {
            closeTimer.cancel();
            closing = false;
        }

        if (isTooltipOpen()) {
            closeNow();
        }

        setTooltipText(info);
        updatePosition(event, isFocused);

        if (BrowserInfo.get().isIOS()) {
            element.focus();
        }

        showTooltip(domEvent instanceof MouseDownEvent && elementIsIndicator);
    }

    handledByFocus = isFocused;
    currentElement = element;
}
 
Example 7
Source File: EventPreviewAutoHiderRegistrar.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Override
public void onPreviewNativeEvent(NativePreviewEvent previewEvent) {
  if (autoHiders.isEmpty()) {
    return;
  }

  // TODO(danilatos,user,user): Push signal down a layer - clean this up.
  Event event = Event.as(previewEvent.getNativeEvent());
  int lowLevelType = event.getTypeInt();

  // TODO(danilatos): Insert this logic deeply rather than
  // sprinkling it in event handlers. Also the return value
  // of onEventPreview is the reverse of signal handlers.
  SignalEvent signal = SignalEventImpl.create(event, false);
  if (signal == null) {
    return;
  }

  // Key events (excluding escape) and mousewheel events use hideTopmostAutoHiderForKeyEvent
  if (lowLevelType == Event.ONMOUSEWHEEL || signal.isKeyEvent()) {
    if (hideTopmostAutoHiderForKeyEvent(false)) {
      // TODO(user): We don't call previewEvent.cancel() here, since for the floating-buttons
      // menu we want, for example, space-bar to still shift focus to the next blip.
      // The to-do is to audit the previewEvent.cancel call below and see why it's there (and if
      // it's not needed, eliminate it).
      return;
    }
  }

  // Pressing escape at any time causes us to close and discard the event.
  if (signal.getKeySignalType() == KeySignalType.NOEFFECT &&
      event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
    if (hideTopmostAutoHiderForKeyEvent(true)) {
      previewEvent.cancel();
      return;
    }
  }

  // Click events and mouse-wheel events that fall through use hideAllAfter.
  if (lowLevelType == Event.ONMOUSEDOWN || lowLevelType == Event.ONMOUSEWHEEL) {
    hideAllAfter(signal.getTarget());
  }

  // Otherwise we don't do anything and the event continues as usual.
}
 
Example 8
Source File: EventPreviewAutoHiderRegistrar.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
@Override
public void onPreviewNativeEvent(NativePreviewEvent previewEvent) {
  if (autoHiders.isEmpty()) {
    return;
  }

  // TODO(danilatos,user,user): Push signal down a layer - clean this up.
  Event event = Event.as(previewEvent.getNativeEvent());
  int lowLevelType = event.getTypeInt();

  // TODO(danilatos): Insert this logic deeply rather than
  // sprinkling it in event handlers. Also the return value
  // of onEventPreview is the reverse of signal handlers.
  SignalEvent signal = SignalEventImpl.create(event, false);
  if (signal == null) {
    return;
  }

  // Key events (excluding escape) and mousewheel events use hideTopmostAutoHiderForKeyEvent
  if (lowLevelType == Event.ONMOUSEWHEEL || signal.isKeyEvent()) {
    if (hideTopmostAutoHiderForKeyEvent(false)) {
      // TODO(user): We don't call previewEvent.cancel() here, since for the floating-buttons
      // menu we want, for example, space-bar to still shift focus to the next blip.
      // The to-do is to audit the previewEvent.cancel call below and see why it's there (and if
      // it's not needed, eliminate it).
      return;
    }
  }

  // Pressing escape at any time causes us to close and discard the event.
  if (signal.getKeySignalType() == KeySignalType.NOEFFECT &&
      event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
    if (hideTopmostAutoHiderForKeyEvent(true)) {
      previewEvent.cancel();
      return;
    }
  }

  // Click events and mouse-wheel events that fall through use hideAllAfter.
  if (lowLevelType == Event.ONMOUSEDOWN || lowLevelType == Event.ONMOUSEWHEEL) {
    hideAllAfter(signal.getTarget());
  }

  // Otherwise we don't do anything and the event continues as usual.
}