weimingtom / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
1 stars 0 forks source link

Keystrokes should be more platform independent #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use jsyntaxpane on Macintosh
2. Undo/Redo keys are control-Z/control-Y instead of mac standard 
command-Z/command-Y

I would suggest the following diff to account for different platforms menu keys:

Index: src/main/java/jsyntaxpane/DefaultSyntaxKit.java
===========================================================
========
--- src/main/java/jsyntaxpane/DefaultSyntaxKit.java (revision 45)
+++ src/main/java/jsyntaxpane/DefaultSyntaxKit.java (working copy)
@@ -15,6 +15,8 @@

 import java.awt.Font;
 import java.awt.GraphicsEnvironment;
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Properties;
@@ -92,8 +94,8 @@
      * @param map
      */
     public void addKeyActions(Keymap map) {
-        map.addActionForKeyStroke(KeyStroke.getKeyStroke("control Z"), 
SyntaxActions.UNDO);
-        map.addActionForKeyStroke(KeyStroke.getKeyStroke("control Y"), 
SyntaxActions.REDO);
+        map.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_Z, 
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), SyntaxActions.UNDO);
+        map.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_Y, 
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), SyntaxActions.REDO);
         map.addActionForKeyStroke(KeyStroke.getKeyStroke("TAB"), SyntaxActions.INDENT);
         map.addActionForKeyStroke(KeyStroke.getKeyStroke("shift TAB"), SyntaxActions.UNINDENT);
     }
@@ -163,4 +165,4 @@
         Arrays.sort(types);
         return types;
     }
-}
\ No newline at end of file
+}

Original issue reported on code.google.com by curtis.s...@gmail.com on 9 Oct 2008 at 8:14

GoogleCodeExporter commented 9 years ago
Thanks for the report and code.
Will test and release with next version.  

Original comment by ayman.al...@gmail.com on 11 Oct 2008 at 6:11

GoogleCodeExporter commented 9 years ago
Now fixed in Release 0.92 - alpha and in in the release

Original comment by ayman.al...@gmail.com on 21 Oct 2008 at 7:37