List of usage examples for javax.swing KeyStroke getKeyCode
public final int getKeyCode()
From source file:org.wings.plaf.css.FrameCG.java
private void appendStrokes(StringBuilder builder, SComponent component, int condition, InputMap inputMap) { KeyStroke[] keyStrokes = inputMap.keys(); if (keyStrokes != null) { for (int i = 0; i < keyStrokes.length; i++) { KeyStroke keyStroke = keyStrokes[i]; Object binding = inputMap.get(keyStroke); switch (keyStroke.getKeyEventType()) { case KeyEvent.KEY_PRESSED: builder.append("kss.push(new ks('"); builder.append(component.getName()); builder.append("',"); builder.append(/*w w w.j av a 2 s.co m*/ condition == SComponent.WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT ? "!0" : "!1"); builder.append(",'"); builder.append(binding); builder.append("',"); builder.append(keyStroke.getKeyCode()); builder.append(','); builder.append((keyStroke.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0 ? "!0" : "!1"); builder.append(','); builder.append((keyStroke.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0 ? "!0" : "!1"); builder.append(','); builder.append((keyStroke.getModifiers() & InputEvent.ALT_DOWN_MASK) != 0 ? "!0" : "!1"); builder.append("));\n"); break; case KeyEvent.KEY_TYPED: break; case KeyEvent.KEY_RELEASED: break; } } } }
From source file:org.wings.plaf.css.InputMapScriptListener.java
private static void writeMatch(StringBuffer buffer, KeyStroke keyStroke) { buffer.append("if (event.keyCode == " + keyStroke.getKeyCode()); if ((keyStroke.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0) buffer.append(" && event.shiftKey"); else//from ww w.j av a2 s .co m buffer.append(" && !event.shiftKey"); if ((keyStroke.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0) buffer.append(" && event.ctrlKey"); else buffer.append(" && !event.ctrlKey"); if ((keyStroke.getModifiers() & InputEvent.ALT_DOWN_MASK) != 0) buffer.append(" && event.altKey"); else buffer.append(" && !event.altKey"); buffer.append(")"); }
From source file:org.zaproxy.zap.extension.keyboard.ExtensionKeyboard.java
private KeyboardMapping menuToMapping(ZapMenuItem menuItem) { KeyStroke ks = this.getKeyboardParam().getShortcut(menuItem.getIdenfifier()); if (ks != null) { if (ks.getKeyCode() == 0) { // Used to indicate no accelerator should be used logger.debug("Cleaning menu " + menuItem.getIdenfifier() + " accelerator"); menuItem.setAccelerator(null); } else {//from w w w . j ava 2s.co m logger.debug("Setting menu " + menuItem.getIdenfifier() + " accelerator to " + ks.toString()); menuItem.setAccelerator(ks); } } return new KeyboardMapping(menuItem); }
From source file:org.zaproxy.zap.extension.keyboard.ExtensionKeyboard.java
private KeyboardShortcut menuToShortcut(ZapMenuItem menuItem, boolean reset) { if (reset) {/*from www. jav a2 s . c o m*/ return new KeyboardShortcut(menuItem.getIdenfifier(), menuItem.getText(), menuItem.getDefaultAccelerator()); } KeyStroke ks = this.getKeyboardParam().getShortcut(menuItem.getIdenfifier()); if (ks != null) { if (ks.getKeyCode() == 0) { // Used to indicate no accelerator should be used logger.debug("Cleaning menu " + menuItem.getIdenfifier() + " accelerator"); menuItem.setAccelerator(null); } else { logger.debug("Setting menu " + menuItem.getIdenfifier() + " accelerator to " + ks.toString()); menuItem.setAccelerator(ks); } } return new KeyboardShortcut(menuItem.getIdenfifier(), menuItem.getText(), menuItem.getAccelerator()); }