/** * This method fires MenuKeyEvent to registered listeners. * Different types of MenuKeyEvents are fired depending * on the observed key event. * * @param event DOCUMENT ME! */ public void processMenuKeyEvent(MenuKeyEvent event) { switch (event.getID()) { case KeyEvent.KEY_PRESSED: fireMenuKeyPressed(event); break; case KeyEvent.KEY_RELEASED: fireMenuKeyReleased(event); break; case KeyEvent.KEY_TYPED: fireMenuKeyTyped(event); break; default: break; } }
public void processKeyEvent(final KeyEvent event, final MenuElement[] path, final MenuSelectionManager manager) { final MenuKeyEvent menuKeyEvent = new MenuKeyEvent(event.getComponent(), event.getID(), event.getWhen(), event.getModifiersEx(), event.getKeyCode(), event.getKeyChar(), path, manager); processMenuKeyEvent(menuKeyEvent); if (menuKeyEvent.isConsumed()) { event.consume(); return; } if (processMnemonics(event)) { event.consume(); return; } }
public void testFireMenuKeyReleased() { MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0], new MenuSelectionManager()); ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener(); ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener(); menuItem.addMenuKeyListener(listener1); menuItem.addMenuKeyListener(listener2); menuItem.fireMenuKeyReleased(event1); assertEquals("event fired properly ", "released", listener1.event); assertEquals("event fired properly ", "released", listener2.event); assertSame("one event fired ", listener1.event, listener2.event); menuItem.fireMenuKeyReleased(event1); assertEquals("event fired properly ", "released", listener1.event); assertEquals("event fired properly ", "released", listener2.event); assertSame("one event fired ", listener1.event, listener2.event); }
public void testFireMenuKeyTyped() { MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0], new MenuSelectionManager()); ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener(); ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener(); menuItem.addMenuKeyListener(listener1); menuItem.addMenuKeyListener(listener2); menuItem.fireMenuKeyTyped(event1); assertEquals("event fired properly ", "typed", listener1.event); assertEquals("event fired properly ", "typed", listener2.event); assertSame("one event fired ", listener1.event, listener2.event); menuItem.fireMenuKeyTyped(event1); assertEquals("event fired properly ", "typed", listener1.event); assertEquals("event fired properly ", "typed", listener2.event); assertSame("one event fired ", listener1.event, listener2.event); }
public void testProcessMenuKeyEvent() { final MenuSelectionManager menuSelectionManager = new MenuSelectionManager(); MenuKeyEvent event1 = new MenuKeyEvent(menuItem, KeyEvent.KEY_PRESSED, 0, 0, 0, 'a', new MenuElement[0], menuSelectionManager); MenuKeyEvent event2 = new MenuKeyEvent(menuItem, KeyEvent.KEY_RELEASED, 0, 0, 0, 'b', new MenuElement[0], menuSelectionManager); MenuKeyEvent event3 = new MenuKeyEvent(menuItem, KeyEvent.KEY_TYPED, 0, 0, 0, 'c', new MenuElement[0], menuSelectionManager); ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener(); menuItem.addMenuKeyListener(listener1); menuItem.processMenuKeyEvent(event1); assertEquals("event fired properly ", "pressed", listener1.event); menuItem.processMenuKeyEvent(event2); assertEquals("event fired properly ", "released", listener1.event); menuItem.processMenuKeyEvent(event3); assertEquals("event fired properly ", "typed", listener1.event); }
@Override public void menuKeyPressed(MenuKeyEvent e) { if (e.getKeyCode() == mnemonic) { ActionEvent ae = new ActionEvent(e.getSource(), e.getID(), (String) getValue(Action.NAME), e.getModifiers()); actionPerformed(ae); e.consume(); } }
@Override final public void menuKeyPressed(MenuKeyEvent objPmenuKeyEvent) { int intLkeysModifiers = objPmenuKeyEvent.getModifiers(); final int intLaltMask = InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK | InputEvent.ALT_GRAPH_DOWN_MASK; if (Tools.intersects(intLkeysModifiers, intLaltMask)) { // Tools.debug("Yep !"); intLkeysModifiers ^= intLaltMask; PatternsFileJCheckBoxMenuItem.setKeysModifiers(intLkeysModifiers); return; } PatternsFileJCheckBoxMenuItem.setKeysModifiers(objPmenuKeyEvent.getModifiers()); }
@Override final public void menuKeyReleased(MenuKeyEvent objPmenuKeyEvent) { int intLkeysModifiers = objPmenuKeyEvent.getModifiers(); final int intLaltMask = InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK | InputEvent.ALT_GRAPH_DOWN_MASK; if (Tools.intersects(intLkeysModifiers, intLaltMask)) { Tools.debug("Yep !"); intLkeysModifiers ^= intLaltMask; PatternsFileJCheckBoxMenuItem.setKeysModifiers(intLkeysModifiers); return; } PatternsFileJCheckBoxMenuItem.setKeysModifiers(objPmenuKeyEvent.getModifiers()); }
/** * Maps {@code JMenuItem.processMenuKeyEvent(MenuKeyEvent)} through queue */ public void processMenuKeyEvent(final MenuKeyEvent menuKeyEvent) { runMapping(new MapVoidAction("processMenuKeyEvent") { @Override public void map() { ((JMenuItem) getSource()).processMenuKeyEvent(menuKeyEvent); } }); }
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(); } }
private void processMenuKeyEvent(MenuKeyEvent e) { switch (e.getID()) { case KeyEvent.KEY_PRESSED: fireMenuKeyPressed(e); break; case KeyEvent.KEY_RELEASED: fireMenuKeyReleased(e); break; case KeyEvent.KEY_TYPED: fireMenuKeyTyped(e); break; default: break; } }
private void fireMenuKeyPressed(MenuKeyEvent event) { Object[] listeners = list.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == MenuKeyListener.class) { ((MenuKeyListener) listeners[i + 1]).menuKeyPressed(event); } } }
private void fireMenuKeyReleased(MenuKeyEvent event) { Object[] listeners = list.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == MenuKeyListener.class) { ((MenuKeyListener) listeners[i + 1]).menuKeyReleased(event); } } }
private void fireMenuKeyTyped(MenuKeyEvent event) { Object[] listeners = list.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == MenuKeyListener.class) { ((MenuKeyListener) listeners[i + 1]).menuKeyTyped(event); } } }
/** * Process key events forwarded from MenuSelectionManager. * * @param event event forwarded from MenuSelectionManager * @param path path to the menu element from which event was generated * @param manager MenuSelectionManager for the current menu hierarchy */ public void processKeyEvent(KeyEvent event, MenuElement[] path, MenuSelectionManager manager) { MenuKeyEvent e = new MenuKeyEvent(event.getComponent(), event.getID(), event.getWhen(), event.getModifiers(), event.getKeyCode(), event.getKeyChar(), path, manager); processMenuKeyEvent(e); // Consume original key event, if the menu key event has been consumed. if (e.isConsumed()) event.consume(); }
/** * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners. * * @param event The event signifying that key associated with this menu was pressed */ protected void fireMenuKeyPressed(MenuKeyEvent event) { EventListener[] ll = listenerList.getListeners(MenuKeyListener.class); for (int i = 0; i < ll.length; i++) ((MenuKeyListener) ll[i]).menuKeyPressed(event); }
/** * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners. * * @param event The event signifying that key associated with this menu was released */ protected void fireMenuKeyReleased(MenuKeyEvent event) { EventListener[] ll = listenerList.getListeners(MenuKeyListener.class); for (int i = 0; i < ll.length; i++) ((MenuKeyListener) ll[i]).menuKeyTyped(event); }
/** * This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners. * * @param event The event signifying that key associated with this menu was typed. * The key is typed when it was pressed and then released */ protected void fireMenuKeyTyped(MenuKeyEvent event) { EventListener[] ll = listenerList.getListeners(MenuKeyListener.class); for (int i = 0; i < ll.length; i++) ((MenuKeyListener) ll[i]).menuKeyTyped(event); }
@Override public void processMenuKeyEvent(final MenuKeyEvent ev) { switch (ev.getKeyCode()) { case KeyEvent.VK_ESCAPE: break; default: redirectEvent(ev); } if (!ev.isConsumed()) { super.processMenuKeyEvent(ev); } }
@Override public void menuKeyPressed(MenuKeyEvent e) { if (e.isControlDown() && isHovered) { if (ctrlLabel != null) { setIcon(ctrlLabel.getIcon()); setText(ctrlLabel.getText()); } } else if (e.isShiftDown() && isHovered) { if (shiftLabel != null) { setIcon(shiftLabel.getIcon()); setText(shiftLabel.getText()); } } repaint(); }
public void processMenuKeyEvent(final MenuKeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { fireMenuKeyPressed(e); } else if (e.getID() == KeyEvent.KEY_RELEASED) { fireMenuKeyReleased(e); } else if (e.getID() == KeyEvent.KEY_TYPED) { fireMenuKeyTyped(e); } }
public void testFireMenuKeyPressed() { MenuKeyEvent event1 = new MenuKeyEvent(menuItem, 0, 0, 0, 0, 'a', new MenuElement[0], new MenuSelectionManager()); ConcreteMenuKeyListener listener1 = new ConcreteMenuKeyListener(); ConcreteMenuKeyListener listener2 = new ConcreteMenuKeyListener(); menuItem.addMenuKeyListener(listener1); menuItem.addMenuKeyListener(listener2); menuItem.fireMenuKeyPressed(event1); assertEquals("event fired properly ", "pressed", listener1.event); assertEquals("event fired properly ", "pressed", listener2.event); menuItem.fireMenuKeyPressed(event1); assertEquals("event fired properly ", "pressed", listener1.event); assertEquals("event fired properly ", "pressed", listener2.event); }