[Jsxe-cvs] SF.net SVN: jsxe: [1006] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-07-11 03:47:03
|
Revision: 1006 Author: ian_lewis Date: 2006-07-10 20:46:50 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1006&view=rev Log Message: ----------- Added code for displaying the grab key dialog Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/Changelog 2006-07-11 03:46:50 UTC (rev 1006) @@ -2,6 +2,8 @@ * Added the Shortcuts option pane. However, it currently it doesn't work. It only displays the built in options and the combo box. + * Updated the shortcuts option pane so that it shows the select shortcut + dialog. 07/06/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-11 03:46:50 UTC (rev 1006) @@ -224,7 +224,8 @@ //{{{ addKeyBinding() /** * Adds a key binding to this input handler. - * @param keyBinding The key binding + * @param keyBinding The key binding. It should be of the form described + * in {@link net.sourceforge.jsxe.gui.KeyEventTranslator} * @param action The action */ public static void addKeyBinding(String keyBinding, LocalizedAction action) { Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java 2006-07-11 03:46:50 UTC (rev 1006) @@ -112,20 +112,19 @@ * removed or the dialog either has been cancelled. Use isOK() * to determine if the latter is true. */ - public String getShortcut() - { - if(isOK) + public String getShortcut() { + if (isOK) { return shortcut.getText(); - else + } else { return null; + } } //}}} //{{{ isOK() method /** * Returns true, if the dialog has not been cancelled. */ - public boolean isOK() - { + public boolean isOK() { return isOK; } //}}} @@ -296,38 +295,49 @@ if (ok != null) { ok.setEnabled(kb == null/* || !kb.isPrefix*/); } - + assignedTo.setText(Messages.getMessage("Grab.Key.assigned-to", new String[] { text })); } //}}} //{{{ getKeyBinding() method - private KeyBinding getKeyBinding(String shortcut) - { - if(shortcut == null || shortcut.length() == 0) + private KeyBinding getKeyBinding(String shortcut) { + + if (shortcut == null || shortcut.length() == 0) { return null; - - String spacedShortcut = shortcut + " "; + } + + Log.log(Log.DEBUG, this, "getting key binding for: "+shortcut); + + // String spacedShortcut = shortcut + " "; Enumeration e = allBindings.elements(); - while(e.hasMoreElements()) - { + while (e.hasMoreElements()) { + KeyBinding kb = (KeyBinding)e.nextElement(); - - if(!kb.isAssigned()) + + if (!kb.isAssigned()) { continue; - - String spacedKbShortcut = kb.shortcut + " "; - + } + + // String spacedKbShortcut = kb.shortcut + " "; + + Log.log(Log.DEBUG, this, "searching "+kb.label+": "+kb.shortcut); + // eg, trying to bind C+n C+p if C+n already bound - if(spacedShortcut.startsWith(spacedKbShortcut)) + // if (spacedShortcut.startsWith(spacedKbShortcut)) { + // return kb; + // } + + if (shortcut.equals(kb.shortcut)) { return kb; - + } + // eg, trying to bind C+e if C+e is a prefix - if(spacedKbShortcut.startsWith(spacedShortcut)) { - // create a temporary (synthetic) prefix - // KeyBinding, that won't be saved - return new KeyBinding(kb.name,kb.label,shortcut); - } + // if (spacedKbShortcut.startsWith(spacedShortcut)) { + // // create a temporary (synthetic) prefix + // // KeyBinding, that won't be saved + // return new KeyBinding(kb.name,kb.label,shortcut); + // } } return null; @@ -369,9 +379,9 @@ } //}}} //{{{ processKeyEvent() method - protected void processKeyEvent(KeyEvent evt) { - // KeyEvent evt = KeyEventWorkaround.processKeyEvent(_evt); - // Log.log(Log.DEBUG, this, "Event " + GrabKeyDialog.toString(_evt) + (evt == null ? " filtered\n" : " passed\n")); + protected void processKeyEvent(KeyEvent _evt) { + KeyEvent evt = KeyEventWorkaround.processKeyEvent(_evt); + Log.log(Log.DEBUG, this, "Event " + GrabKeyDialog.toString(_evt) + (evt == null ? " filtered\n" : " passed\n")); if (evt == null) { return; @@ -379,41 +389,33 @@ evt.consume(); - // KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(evt); - // if (key == null) { - // return; - // } + KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(evt); + if (key == null) { + return; + } - // Log.log(Log.DEBUG, this, "==> Translated to " + key + "\n"); + Log.log(Log.DEBUG, this, "==> Translated to " + key + "\n"); - StringBuffer keyString = new StringBuffer(getText()); + StringBuffer keyString = new StringBuffer(); - // if (getDocument().getLength() != 0) { - // keyString.append(' '); - // } - - // if (key.modifiers != null) { - // keyString.append(key.modifiers).append('+'); - // } - - if (evt.getModifiers() != 0) { - keyString.append(KeyEvent.getKeyModifiersText(evt.getModifiers())).append(' '); + if (key.modifiers != null) { + keyString.append(key.modifiers).append('+'); } - if (evt.getKeyCode() == KeyEvent.VK_SPACE) { + if (key.input == ' ') { keyString.append("SPACE"); } else { - // if (key.input != '\0') { - keyString.append(KeyEvent.getKeyText(evt.getKeyCode())); - // } else { - // String symbolicName = getSymbolicName(key.key); + if (key.input != '\0') { + keyString.append(key.input); + } else { + String symbolicName = getSymbolicName(key.key); - // if (symbolicName == null) { - // return; - // } + if (symbolicName == null) { + return; + } - // keyString.append(symbolicName); - // } + keyString.append(symbolicName); + } } setText(keyString.toString()); Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-07-11 00:14:33 UTC (rev 1005) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-07-11 03:46:50 UTC (rev 1006) @@ -52,7 +52,7 @@ #}}} #{{{ Default key bindings -open-file.shortcut=ctrl O +open-file.shortcut=ctrl ENTER exit.shortcut=ctrl Q close-file.shortcut=ctrl W new-file.shortcut=ctrl N This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |