/**
  * Processes key stroke events such as mnemonics and accelerators.
  *
  * @param evt the key event to be processed
  */
 protected void processKeyEvent(KeyEvent evt) {
   MenuSelectionManager.defaultManager().processKeyEvent(evt);
   if (evt.isConsumed()) {
     return;
   }
   super.processKeyEvent(evt);
 }
Exemple #2
0
 /*
  * Post an ActionEvent to the target (on
  * keydown) and the item is enabled.
  * Returns true if there is an associated shortcut.
  */
 boolean handleShortcut(KeyEvent e) {
   MenuShortcut s =
       new MenuShortcut(e.getKeyCode(), (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
   // Fix For 6185151: Menu shortcuts of all menuitems within a menu
   // should be disabled when the menu itself is disabled
   if (s.equals(shortcut) && isItemEnabled()) {
     // MenuShortcut match -- issue an event on keydown.
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       doMenuEvent(e.getWhen(), e.getModifiers());
     } else {
       // silently eat key release.
     }
     return true;
   }
   return false;
 }
  /**
   * Processes a key event forwarded from the <code>MenuSelectionManager</code> and changes the menu
   * selection, if necessary, by using <code>MenuSelectionManager</code>'s API.
   *
   * <p>Note: you do not have to forward the event to sub-components. This is done automatically by
   * the <code>MenuSelectionManager</code>.
   *
   * @param e a <code>KeyEvent</code>
   * @param path the <code>MenuElement</code> path array
   * @param manager the <code>MenuSelectionManager</code>
   */
  public void processKeyEvent(KeyEvent e, MenuElement path[], MenuSelectionManager manager) {
    MenuKeyEvent mke =
        new MenuKeyEvent(
            e.getComponent(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            e.getKeyCode(),
            e.getKeyChar(),
            path,
            manager);
    processMenuKeyEvent(mke);

    if (mke.isConsumed()) {
      e.consume();
    }
  }