當前位置: 首頁>>代碼示例>>Java>>正文


Java Event.ONKEYDOWN屬性代碼示例

本文整理匯總了Java中com.google.gwt.user.client.Event.ONKEYDOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java Event.ONKEYDOWN屬性的具體用法?Java Event.ONKEYDOWN怎麽用?Java Event.ONKEYDOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.gwt.user.client.Event的用法示例。


在下文中一共展示了Event.ONKEYDOWN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
	if (!isEnabled()) return;

	super.onBrowserEvent(event);

    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
    	int type = DOM.eventGetType(event);
    	char keyCode = (char) event.getKeyCode();
    	switch (type) {
    	case Event.ONKEYDOWN:
    		if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
    			if (iDown != null) setResource(iDown);
    		}
    		break;
        case Event.ONKEYUP:
        	if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
        		setResource(iUp);
        		onClick();
        	}
        	break;
    	}
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:24,代碼來源:ImageButton.java

示例2: onEventPreview

@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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,代碼來源:CubaNotification.java

示例3: maybeNullWebkitIE

/**
 * Common logic between Webkit and IE for deciding whether we want the keydown
 * or the keypress
 */
private static boolean maybeNullWebkitIE(boolean ret, int typeInt,
    KeySignalType type) {
  // Use keydown as the signal for everything except input.
  // This is because the mutation always happens after the keypress for
  // input (this is especially important for chrome,
  // which interleaves deferred commands between keydown and keypress).
  //
  // For everything else, keypress is redundant with keydown, and also, the resulting default
  // dom mutation (if any) often happens after the keydown but before the keypress in webkit.
  // Also, if the 'Command' key is held for chrome/safari etc, we want to get the keydown
  // event, NOT the keypress event, for everything because of things like ctrl+c etc.
  // where sometimes it'll happen just after the keydown, or sometimes we just won't
  // get a keypress at all
  if (typeInt == (type == KeySignalType.INPUT ? Event.ONKEYDOWN : Event.ONKEYPRESS)) {
    return false;
  }

  return ret;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:23,代碼來源:SignalKeyLogic.java

示例4: onBrowserEvent

/**
 * Overridden to send ValueChangeEvents only when appropriate.
 */
@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEUP:
        case Event.ONBLUR:
        case Event.ONKEYDOWN:
            // Note the old value for onValueChange purposes (in ONCLICK case)
            oldValue = getValue();
            break;

        case Event.ONCLICK:
            EventTarget target = event.getEventTarget();
            if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {

                // They clicked the label. Note our pre-click value, and
                // short circuit event routing so that other click handlers
                // don't hear about it
                oldValue = getValue();
                return;
            }

            // It's not the label. Let our handlers hear about the
            // click...
            super.onBrowserEvent(event);
            // ...and now maybe tell them about the change
            ValueChangeEvent.fireIfNotEqual(AccessibleRadioButton.this, oldValue, getValue());
            return;
    }

    super.onBrowserEvent(event);
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:34,代碼來源:AccessibleRadioButton.java

示例5: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);

    if (type == Event.ONKEYDOWN && shortcutHandler != null) {
        shortcutHandler.handleKeyboardEvent(event);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:10,代碼來源:CubaDateFieldWidget.java

示例6: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN && shortcutHandler != null) {
        shortcutHandler.handleKeyboardEvent(event);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:9,代碼來源:CubaGridLayoutWidget.java

示例7: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN && _delegate.shortcutHandler != null) {
        _delegate.shortcutHandler.handleKeyboardEvent(event);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:9,代碼來源:CubaTreeTableWidget.java

示例8: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
    int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN
            && event.getKeyCode() == KeyCodes.KEY_ENTER
            && !event.getAltKey()
            && !event.getShiftKey()
            && !event.getCtrlKey()) {
        event.stopPropagation();
        return;
    }

    super.onBrowserEvent(event);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:14,代碼來源:CubaSourceCodeEditorWidget.java

示例9: modifiers

/**
 * @return A string describing which modifier keys were pressed,
 *        and whether this was a repeat event,  e.g., " shift ctrl"
 */
@SuppressWarnings("deprecation")
public static String modifiers(Event event) {
  // repeat is deprecated, but useful for debugging
  return (event.getAltKey() ? " alt" : "")
  + (event.getShiftKey() ? " shift" : "")
  + (event.getCtrlKey() ? " ctrl" : "")
  + (event.getMetaKey() ? " meta" : "")
  + ((event.getTypeInt() == Event.ONKEYDOWN) && event.getRepeat() ? " repeat" : "");
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:13,代碼來源:EventWrapper.java

示例10: asString

public static String asString(Event event) {
  // Start with the event type string
  String string = DOM.eventGetTypeString(event);
  // Next type-specific fields
  switch (event.getTypeInt()) {
  case Event.ONKEYPRESS:
  case Event.ONKEYUP:
  case Event.ONKEYDOWN:
    string += key(event) + modifiers(event);
    break;
  case Event.ONCLICK:
  case Event.ONDBLCLICK:
  case Event.ONMOUSEMOVE:
    string += mousePoint(event) + modifiers(event);
    break;
  case Event.ONMOUSEDOWN:
  case Event.ONMOUSEUP:
    string += mousePoint(event) + mouseButtons(event) + modifiers(event);
    break;
  case Event.ONMOUSEOUT:
    string += mousePoint(event) + modifiers(event) + " to: " + getToElement(event);
    break;
  case Event.ONMOUSEOVER:
    string += mousePoint(event) + modifiers(event) + " from: " + getFromElement(event);
    break;
  case Event.ONMOUSEWHEEL:
    string += " " + getMouseWheelVelocityY(event) + mousePoint(event) + modifiers(event);
    break;
  case Event.ONFOCUS:
  case Event.ONBLUR:
  case Event.ONCHANGE:
  case Event.ONERROR:
  case Event.ONLOAD:
  case Event.ONLOSECAPTURE:
  case Event.ONSCROLL:
    break;
  }
  return string;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:39,代碼來源:EventWrapper.java

示例11: isKeyPressEvent

private boolean isKeyPressEvent(EditorDomEvent<Object> event) {
    return event.getDomEvent().getTypeInt() == Event.ONKEYDOWN;
}
 
開發者ID:TatuLund,項目名稱:GridFastNavigation,代碼行數:3,代碼來源:EditorStateManager.java

示例12: handleKeyboardEvents

@Override
protected boolean handleKeyboardEvents(Event event) {
    int type = DOM.eventGetType(event);
    // Synthesize clicks based on keyboard events AFTER the normal key
    // handling.
    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
        switch (type) {
            case Event.ONKEYDOWN:
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                // Stop propagation when the user starts pressing a button that
                // we are handling to prevent actions from getting triggered
                if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                    isFocusing = true;
                    event.preventDefault();
                    event.stopPropagation();
                    return true;
                } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                    isFocusing = true;
                    event.stopPropagation();
                    return true;
                } else if (event.getKeyCode() == KeyCodes.KEY_DOWN) {
                    isFocusing = true;
                    event.stopPropagation();
                }
                break;

            // CAUTION IE sometimes does not generate ONKEYPRESS for ENTER, so we override default Vaadin behavior
            case Event.ONKEYUP:
                if (isFocusing) {
                    if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    } else if (event.getKeyCode() == KeyCodes.KEY_DOWN) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    }
                } else if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                break;
            case Event.ONKEYPRESS: {
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:72,代碼來源:CubaPopupButtonWidget.java

示例13: onBrowserEvent

@Override
public void onBrowserEvent(Event event) {
    if (getElement() == DOM.eventGetTarget(event)) {
        return;
    }

    SuggestionItem item = findItem(DOM.eventGetTarget(event));
    switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEDOWN: {
            if (BrowserInfo.get().isIE()) {
                suggestionFieldWidget.iePreventBlur = true;
            }
            break;
        }

        case Event.ONCLICK: {
            if (event.getButton() == NativeEvent.BUTTON_LEFT) {
                performItemCommand(item);
            }
            break;
        }

        case Event.ONMOUSEOVER: {
            if (item != null) {
                selectItem(item);
            }
            break;
        }

        case Event.ONKEYDOWN: {
            int keyCode = KeyCodes.maybeSwapArrowKeysForRtl(
                    event.getKeyCode(),
                    LocaleInfo.getCurrentLocale().isRTL()
            );

            switch (keyCode) {
                case KeyCodes.KEY_UP:
                    selectPrevItem();
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_DOWN:
                    selectNextItem();
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_ESCAPE:
                    selectItem(null);
                    preventEvent(event);
                    break;
                case KeyCodes.KEY_TAB:
                    selectItem(null);
                    break;
                case KeyCodes.KEY_ENTER:
                    performItemCommand(item);
                    preventEvent(event);
                    break;
            }
            break;
        }
    }
    super.onBrowserEvent(event);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:61,代碼來源:SuggestionsContainer.java

示例14: handleKeyboardEvents

@Override
protected boolean handleKeyboardEvents(Event event) {
    int type = DOM.eventGetType(event);
    // Synthesize clicks based on keyboard events AFTER the normal key
    // handling.
    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
        switch (type) {
            case Event.ONKEYDOWN:
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                // Stop propagation when the user starts pressing a button that
                // we are handling to prevent actions from getting triggered
                if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                    isFocusing = true;
                    event.preventDefault();
                    event.stopPropagation();
                    return true;
                } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                    isFocusing = true;
                    event.stopPropagation();
                    return true;
                }
                break;

            // CAUTION IE sometimes does not generate ONKEYPRESS for ENTER, so we override default Vaadin behavior
            case Event.ONKEYUP:
                if (isFocusing) {
                    if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    }
                } else if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                break;
            case Event.ONKEYPRESS: {
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:63,代碼來源:CubaButtonWidget.java

示例15: handleEventInner

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;
    }
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:55,代碼來源:SuggestionMenu.java


注:本文中的com.google.gwt.user.client.Event.ONKEYDOWN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。