Java Code Examples for com.google.gwt.event.dom.client.KeyCodes#KEY_LEFT

The following examples show how to use com.google.gwt.event.dom.client.KeyCodes#KEY_LEFT . 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: EditorEventHandler.java    From swellrt with Apache License 2.0 6 votes vote down vote up
private boolean handleNavigationKeyEvents(EditorEvent event) {
  editorInteractor.checkpoint(null);
  editorInteractor.clearCaretAnnotations();
  ContentNode node = cachedSelection.getFocus().getContainer();
  logger.trace().log("Navigation event");

  // Not using key combo, because we want to handle left key with
  // any modifiers also applying.
  // TODO(danilatos): MoveUnit, and holding down shift for selection.
  if (event.getKeyCode() == KeyCodes.KEY_LEFT) {
    router.handleLeft(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_RIGHT);
    return !event.shouldAllowBrowserDefault();
  } else if (event.getKeyCode() == KeyCodes.KEY_RIGHT) {
    router.handleRight(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return !event.shouldAllowBrowserDefault();
  } else {
    editorInteractor.rebiasSelection(CursorDirection.NEUTRAL);
  }
  return false;
}
 
Example 2
Source File: AutoSizingBase.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
protected void onKeyCodeEvent(KeyCodeEvent event, String newShadowText) {
// ignore arrow keys
switch (event.getNativeKeyCode()) {
case KeyCodes.KEY_UP:
case KeyCodes.KEY_DOWN:
case KeyCodes.KEY_LEFT:
case KeyCodes.KEY_RIGHT:
    break;
default:
    // don't do this if there's a selection because it will get smaller
    if (box.getSelectionLength() == 0) {
	setShadowText(newShadowText);
	adjustSize();	    
	break;
    }
}	
   }
 
Example 3
Source File: EditorEventHandler.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
private boolean handleNavigationKeyEvents(EditorEvent event) {
  editorInteractor.checkpoint(null);
  editorInteractor.clearCaretAnnotations();
  ContentNode node = cachedSelection.getFocus().getContainer();
  logger.trace().log("Navigation event");

  // Not using key combo, because we want to handle left key with
  // any modifiers also applying.
  // TODO(danilatos): MoveUnit, and holding down shift for selection.
  if (event.getKeyCode() == KeyCodes.KEY_LEFT) {
    router.handleLeft(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_RIGHT);
    return !event.shouldAllowBrowserDefault();
  } else if (event.getKeyCode() == KeyCodes.KEY_RIGHT) {
    router.handleRight(node, event);
    editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
    return !event.shouldAllowBrowserDefault();
  } else {
    editorInteractor.rebiasSelection(CursorDirection.NEUTRAL);
  }
  return false;
}
 
Example 4
Source File: CellBrowser.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBrowserEvent2(Event event) {
  super.onBrowserEvent2(event);

  // Handle keyboard navigation between lists.
  String eventType = event.getType();
  if (BrowserEvents.KEYDOWN.equals(eventType) && !isKeyboardNavigationSuppressed()) {
    int keyCode = event.getKeyCode();
    boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
    keyCode = KeyCodes.maybeSwapArrowKeysForRtl(keyCode, isRtl);
    switch (keyCode) {
      case KeyCodes.KEY_LEFT:
        keyboardNavigateShallow();
        return;
      case KeyCodes.KEY_RIGHT:
        keyboardNavigateDeep();
        return;
    }
  }
}
 
Example 5
Source File: EventUtils.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isArrowKey(int keyCode) {
	if (KeyCodes.KEY_LEFT == keyCode || KeyCodes.KEY_RIGHT == keyCode || KeyCodes.KEY_UP == keyCode
			|| KeyCodes.KEY_DOWN == keyCode) {
		return true;
	} else {
		return false;
	}
}
 
Example 6
Source File: InputSlider.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onKeyDown(KeyDownEvent event) {
	if (!InputSlider.this.isStateValid()) {
		return;
	}
	int paddingValue = 1;
	if (event.isControlKeyDown()) {
		paddingValue = InputSlider.this.items.size() / 5;
	}
	switch (event.getNativeKeyCode()) {
		case KeyCodes.KEY_HOME:
			InputSlider.this.handleWidget.moveStart();
			this.killEvent(event);
			break;
		case KeyCodes.KEY_END:
			InputSlider.this.handleWidget.moveEnd();
			this.killEvent(event);
			break;
		case KeyCodes.KEY_SPACE:
			InputSlider.this.handleWidget.moveMiddle();
			this.killEvent(event);
			break;
		case KeyCodes.KEY_LEFT:
			InputSlider.this.handleWidget.moveLeft(paddingValue);
			this.killEvent(event);
			break;
		case KeyCodes.KEY_RIGHT:
			InputSlider.this.handleWidget.moveRight(paddingValue);
			this.killEvent(event);
			break;
		default:
			break;
	}
}
 
Example 7
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 8
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean handleKeyPress(int keyCode) {
	if (KeyEventUtils.isModifierKeyDown(Event.getCurrentEvent())) {
		return false;
	}
	boolean handleKey = false;
	switch (keyCode) {
		case KeyCodes.KEY_LEFT:
			CalendarUtil.addDaysToDate(this.cursor, -1);
			handleKey = true;
			break;
		case KeyCodes.KEY_RIGHT:
			CalendarUtil.addDaysToDate(this.cursor, 1);
			handleKey = true;
			break;
		case KeyCodes.KEY_UP:
			CalendarUtil.addDaysToDate(this.cursor, -7);
			handleKey = true;
			break;
		case KeyCodes.KEY_DOWN:
			CalendarUtil.addDaysToDate(this.cursor, 7);
			handleKey = true;
			break;
		case KeyCodes.KEY_PAGEUP:
			CalendarUtil.addMonthsToDate(this.cursor, -1);
			handleKey = true;
			break;
		case KeyCodes.KEY_PAGEDOWN:
			CalendarUtil.addMonthsToDate(this.cursor, 1);
			handleKey = true;
			break;
		case KeyCodes.KEY_ENTER:
			this.setValue(this.cursor, true);
			handleKey = true;
			break;
		case KeyCodes.KEY_ESCAPE:
			this.setValue(this.value);
			this.setFocus(false);
			handleKey = true;
			break;
		default:
			break;
	}
	if (handleKey) {
		this.redraw();
	}

	return handleKey;
}
 
Example 9
Source File: MaskValueBoxHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void onKeyDown(KeyDownEvent event) {
	this.keyDown = event.getNativeKeyCode();
	boolean preventDefault = false;
	switch (event.getNativeKeyCode()) {
		case KeyCodes.KEY_DELETE:
		case KeyCodes.KEY_BACKSPACE:
			if (this.token != null) {
				this.reset();
				this.maskHelper.refreshValueBox();
				event.preventDefault();
			}
			break;
		case KeyCodes.KEY_DOWN:
		case KeyCodes.KEY_UP:
			event.preventDefault();
			break;
		case KeyCodes.KEY_LEFT:
			preventDefault = this.maskHelper.focusPrevious();
			break;
		case KeyCodes.KEY_RIGHT:
			preventDefault = this.maskHelper.focusNext();

			break;
		case KeyCodes.KEY_TAB:
			if (event.isShiftKeyDown()) {
				preventDefault = this.maskHelper.focusPrevious();
			} else {
				preventDefault = this.maskHelper.focusNext();
			}
			break;
		default:
			break;
	}

	if (preventDefault) {
		event.preventDefault();
	}
	if (this.handleKeyDown(this.keyDown)) {
		this.maskHelper.refreshValueBox();
		this.schedule(this.maskHelper.initialDelayMilis);
	}
}
 
Example 10
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;
    }
  }
}