com.google.gwt.user.client.Event.getKeyCode()方法的使用及代码示例

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

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

Event.getKeyCode介绍

暂无

代码示例

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

/**
 * Gets the key code associated with this event.
 * 
 * <p>
 * For {@link Event#ONKEYPRESS}, this method returns the Unicode value of the
 * character generated. For {@link Event#ONKEYDOWN} and {@link Event#ONKEYUP},
 * it returns the code associated with the physical key.
 * </p>
 * 
 * @param evt the event to be tested
 * @return the Unicode character or key code.
 * @see com.google.gwt.user.client.ui.KeyboardListener
 * @deprecated Use {@link Event#getKeyCode()} instead.
 */
@Deprecated
public static int eventGetKeyCode(Event evt) {
 return evt.getKeyCode();
}

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

/**
 * Automatically fires the appropriate keyboard event to all listeners. If the
 * given event is not a keyboard event, no action will be performed.
 * 
 * @param sender the widget sending the event.
 * @param event the Event received by the widget.
 */
public void fireKeyboardEvent(Widget sender, Event event) {
 int modifiers = getKeyboardModifiers(event);
 switch (DOM.eventGetType(event)) {
  case Event.ONKEYDOWN:
   fireKeyDown(sender, (char) event.getKeyCode(), modifiers);
   break;
  case Event.ONKEYUP:
   fireKeyUp(sender, (char) event.getKeyCode(), modifiers);
   break;
  case Event.ONKEYPRESS:
   fireKeyPress(sender, (char) event.getKeyCode(), modifiers);
   break;
 }
}

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

@Override
public void onBrowserEvent(Event event) {
 if (!enabled) {
  return;
 }
 // No need for call to super.
 switch (DOM.eventGetType(event)) {
  case Event.ONCLICK:
   TabBar.this.selectTabByTabWidget(this);
   TabBar.this.onClick(this);
   break;
  case Event.ONKEYDOWN:
   if (((char) event.getKeyCode()) == KeyCodes.KEY_ENTER) {
    TabBar.this.selectTabByTabWidget(this);
   }
   TabBar.this.onKeyDown(this, (char) event.getKeyCode(),
     KeyboardListenerCollection.getKeyboardModifiers(event));
   break;
 }
 super.onBrowserEvent(event);
}

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

@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;
  }
 }
}

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

private void keyboardNavigation(Event event) {
 // Handle keyboard events if keyboard navigation is enabled
 if (isKeyboardNavigationEnabled(curSelection)) {
  int code = event.getKeyCode();
  switch (KeyCodes.maybeSwapArrowKeysForRtl(code, LocaleInfo.getCurrentLocale().isRTL())) {
   case KeyCodes.KEY_UP: {
    moveSelectionUp(curSelection);
    break;
   }
   case KeyCodes.KEY_DOWN: {
    moveSelectionDown(curSelection, true);
    break;
   }
   case KeyCodes.KEY_LEFT: {
    maybeCollapseTreeItem();
    break;
   }
   case KeyCodes.KEY_RIGHT: {
    maybeExpandTreeItem();
    break;
   }
   default: {
    return;
   }
  }
 }
}

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

onBlur();
} else if (BrowserEvents.KEYDOWN.equals(eventType) && !cellIsEditing) {
 int keyCode = event.getKeyCode();
 switch (keyCode) {

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

switch (type) {
 case Event.ONKEYDOWN: {
  if (!onKeyDownPreview((char) nativeEvent.getKeyCode(),
    KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
   event.cancel();
  if (!onKeyUpPreview((char) nativeEvent.getKeyCode(),
    KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
   event.cancel();
  if (!onKeyPressPreview((char) nativeEvent.getKeyCode(),
    KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) {
   event.cancel();

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

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();

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-library-client

@SinkNative(Event.ONBLUR | Event.ONKEYDOWN)
@EventHandler("pageNumber")
public void onPageChange(final Event e) {
  if (e.getKeyCode() < 0 || e.getKeyCode() == KeyCodes.KEY_ENTER) {
    presenter.onPageNumberChange(Integer.valueOf(pageNumber.getValue()));
  }
}

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

String eventType = event.getType();
boolean isSelect = BrowserEvents.CLICK.equals(eventType)
  || (BrowserEvents.KEYDOWN.equals(eventType) && event.getKeyCode() == KeyCodes.KEY_ENTER);

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

@Override
protected boolean keydownChecker(Event e) {
  if (e.getKeyCode() != BACKSPACE) {
    clearBackstroke();
  } else {
    backstrokeLength = getSearchField().val().length();
  }
  return super.keydownChecker(e);
}

代码示例来源:origin: ArcBees/gwtchosen

@Override
protected boolean keydownChecker(Event e) {
  if (e.getKeyCode() != BACKSPACE) {
    clearBackstroke();
  } else {
    backstrokeLength = getSearchField().val().length();
  }
  return super.keydownChecker(e);
}

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

int keyCode = event.getKeyCode();
boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
keyCode = KeyCodes.maybeSwapArrowKeysForRtl(keyCode, isRtl);

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-widgets

@Test
public void testOnChangeNameKeyPressEvent() {
  when(nameField.getValue()).thenReturn(NAME);
  when(event.getTypeInt()).thenReturn(Event.ONKEYPRESS);
  when(event.getKeyCode()).thenReturn(KeyCodes.KEY_A);
  tested.onChangeName(event);
  verify(presenter, times(1)).onKeyPress(eq(KeyCodes.KEY_A), eq(false), eq(NAME));
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-widgets

@Test
public void testOnChangeNameKeyDownEvent() {
  when(nameField.getValue()).thenReturn(NAME);
  when(event.getTypeInt()).thenReturn(Event.ONKEYDOWN);
  when(event.getKeyCode()).thenReturn(KeyCodes.KEY_A);
  tested.onChangeName(event);
  verify(presenter, times(1)).onKeyDown(eq(KeyCodes.KEY_A), eq(NAME));
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-widgets

@Test
public void testOnChangeNameKeyDownEvent() {
  when(nameField.getValue()).thenReturn(NAME);
  when(event.getTypeInt()).thenReturn(Event.ONKEYDOWN);
  when(event.getKeyCode()).thenReturn(KeyCodes.KEY_A);
  tested.onChangeName(event);
  verify(presenter, times(1)).onKeyDown(eq(KeyCodes.KEY_A), eq(NAME));
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-widgets

@Test
public void testOnKeyDownEscEvent() {
  when(event.getTypeInt()).thenReturn(Event.ONKEYDOWN);
  when(event.getKeyCode()).thenReturn(KeyCodes.KEY_ESCAPE);
  tested.editNameBoxEsc(event);
  verify(presenter,
      times(1)).onClose();
}

代码示例来源:origin: com.asayama.docs.gwt.angular/gwt-angular-tutorial

public String onKeyPressQuickEntry(Event event) {
  int keyCode = event.getKeyCode();
  if (keyCode == 13) {
    getEntries().add(Entry.create(quickEntryCaption));
    setQuickEntryCaption("");
  }
  return getQuickEntryCaption();
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-client

public void onBrowserEvent(Event event) {
 switch (event.getTypeInt()) {
  case Event.ONDBLCLICK:
   onDoubleClick(event);
   break;
  default:
   if (event instanceof KeyboardEvent && event.getKeyCode() == KeyboardEvent.KeyCode.ENTER) {
    event.preventDefault();
    event.stopPropagation();
   }
   super.onBrowserEvent(event);
 }
}

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

char keyCode = (char) event.getKeyCode();
switch (type) {
 case Event.ONKEYDOWN:

相关文章