Java Code Examples for com.google.gwt.user.client.Event#ONCONTEXTMENU

The following examples show how to use com.google.gwt.user.client.Event#ONCONTEXTMENU . 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: CubaWindowWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    if (contextMenuHandler != null && event.getTypeInt() == Event.ONCONTEXTMENU) {
        contextMenuHandler.onContextMenu(event);
        return;
    }

    if ((event.getTypeInt() == Event.ONCLICK
            || event.getTypeInt() == Event.ONMOUSEDOWN)
            && event.getButton() != NativeEvent.BUTTON_LEFT) {
        event.preventDefault();
        event.stopPropagation();
        return;
    }

    super.onBrowserEvent(event);
}
 
Example 2
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    if (isEnabled() && event.getTypeInt() == Event.ONCONTEXTMENU) {
        if (getStyleName().contains("-header-sortable")) {
            _delegate.showSortMenu(td, cid);
        }

        event.preventDefault();
        event.stopPropagation();
    }
}
 
Example 3
Source File: CubaScrollTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    if (isEnabled() && event.getTypeInt() == Event.ONCONTEXTMENU) {
        if (getStyleName().contains("-header-sortable")) {
            _delegate.showSortMenu(td, cid);
        }

        event.preventDefault();
        event.stopPropagation();
    }
}
 
Example 4
Source File: SuggestPopup.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (event.getTypeInt() == Event.ONCONTEXTMENU) {
		event.stopPropagation();
		event.preventDefault();
		return;
	}
	super.onBrowserEvent(event);
}
 
Example 5
Source File: SuggestionMenu.java    From swellrt with Apache License 2.0 4 votes vote down vote up
private void handleEventInner(Event event) {
  switch (DOM.eventGetType(event)) {
    case Event.ONCONTEXTMENU:
      event.preventDefault();
      break;
    case Event.ONKEYPRESS:
    case Event.ONKEYDOWN: {
      // NOTE(user): It is necessary to stop propagation on the key events to
      // prevent them from leaking to the blip/wave presenters.
      int keyCode = DOM.eventGetKeyCode(event);

      // Move left/right to previous/next drop down widget
      switch (keyCode) {
        case KeyCodes.KEY_LEFT:
        case KeyCodes.KEY_RIGHT:
          handler.handleLeftRight(keyCode == KeyCodes.KEY_RIGHT);
          event.stopPropagation();
          return;
        case KeyCodes.KEY_ENTER:
          event.stopPropagation();
      }

      if (keyCode >= '1' && keyCode <= '9') {
        // TODO(danilatos): Is this ok? i18n etc?
        int index = keyCode - '1';

        if (index >= 0 && index < getItems().size()) {
          MenuItem item = getItems().get(index);
          if (item == null) {
            return;
          }

          item.getCommand().execute();
          DOM.eventPreventDefault(event);
        }
      }
      break;
    }
    case Event.ONMOUSEOUT: {
      // Need to check that we really seem to have left the menu, as
      // mouse-out events get triggered whenever the mouse moves between
      // selections in the menu.
      EventTarget target = event.getRelatedEventTarget();
      Element targetElement = Element.as(target);
      if (!getElement().isOrHasChild(targetElement)) {
        handler.handleMouseOut();
      }
      break;
    }
    case Event.ONMOUSEOVER: {
      handler.handleMouseOver();
      break;
    }
  }
}
 
Example 6
Source File: SuggestionMenu.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private void handleEventInner(Event event) {
  switch (DOM.eventGetType(event)) {
    case Event.ONCONTEXTMENU:
      event.preventDefault();
      break;
    case Event.ONKEYPRESS:
    case Event.ONKEYDOWN: {
      // NOTE(user): It is necessary to stop propagation on the key events to
      // prevent them from leaking to the blip/wave presenters.
      int keyCode = DOM.eventGetKeyCode(event);

      // Move left/right to previous/next drop down widget
      switch (keyCode) {
        case KeyCodes.KEY_LEFT:
        case KeyCodes.KEY_RIGHT:
          handler.handleLeftRight(keyCode == KeyCodes.KEY_RIGHT);
          event.stopPropagation();
          return;
        case KeyCodes.KEY_ENTER:
          event.stopPropagation();
      }

      if (keyCode >= '1' && keyCode <= '9') {
        // TODO(danilatos): Is this ok? i18n etc?
        int index = keyCode - '1';

        if (index >= 0 && index < getItems().size()) {
          MenuItem item = getItems().get(index);
          if (item == null) {
            return;
          }

          item.getCommand().execute();
          DOM.eventPreventDefault(event);
        }
      }
      break;
    }
    case Event.ONMOUSEOUT: {
      // Need to check that we really seem to have left the menu, as
      // mouse-out events get triggered whenever the mouse moves between
      // selections in the menu.
      EventTarget target = event.getRelatedEventTarget();
      Element targetElement = Element.as(target);
      if (!getElement().isOrHasChild(targetElement)) {
        handler.handleMouseOut();
      }
      break;
    }
    case Event.ONMOUSEOVER: {
      handler.handleMouseOver();
      break;
    }
  }
}