You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/11/02 16:51:43 UTC

svn commit: r1030093 - in /pivot/trunk: tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml tutorials/www/menu-bars.xml wtk/src/org/apache/pivot/wtk/Keyboard.java

Author: gbrown
Date: Tue Nov  2 15:51:43 2010
New Revision: 1030093

URL: http://svn.apache.org/viewvc?rev=1030093&view=rev
Log:
Resolve PIVOT-662 and PIVOT-663.

Modified:
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml
    pivot/trunk/tutorials/www/menu-bars.xml
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java

Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml?rev=1030093&r1=1030092&r2=1030093&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_bars.bxml Tue Nov  2 15:51:43 2010
@@ -27,9 +27,8 @@ limitations under the License.
     </bxml:define>
 
     <actionMappings>
-        <Window.ActionMapping action="cut" keyStroke="CTRL-X"/>
-        <Window.ActionMapping action="copy" keyStroke="CTRL-C"/>
-        <Window.ActionMapping action="paste" keyStroke="CTRL-V"/>
+        <Window.ActionMapping action="fileNew" keyStroke="CMD-N"/>
+        <Window.ActionMapping action="fileOpen" keyStroke="CMD-O"/>
     </actionMappings>
 
     <menuBar>
@@ -37,8 +36,17 @@ limitations under the License.
             <MenuBar.Item buttonData="File">
                 <Menu>
                     <Menu.Section>
-                        <Menu.Item buttonData="New" action="fileNew"/>
-                        <Menu.Item buttonData="Open" action="fileOpen"/>
+                        <Menu.Item action="fileNew">
+                            <buttonData>
+                                <content:MenuItemData text="New" keyboardShortcut="CMD-N"/>
+                            </buttonData>
+                        </Menu.Item>
+
+                        <Menu.Item action="fileOpen">
+                            <buttonData>
+                                <content:MenuItemData text="Open" keyboardShortcut="CMD-O"/>
+                            </buttonData>
+                        </Menu.Item>
                     </Menu.Section>
                 </Menu>
             </MenuBar.Item>
@@ -48,17 +56,17 @@ limitations under the License.
                     <Menu.Section>
                         <Menu.Item action="cut">
                             <buttonData>
-                                <content:MenuItemData text="Cut" keyboardShortcut="CTRL-X"/>
+                                <content:MenuItemData text="Cut" keyboardShortcut="CMD-X"/>
                             </buttonData>
                         </Menu.Item>
                         <Menu.Item action="copy">
                             <buttonData>
-                                <content:MenuItemData text="Copy" keyboardShortcut="CTRL-C"/>
+                                <content:MenuItemData text="Copy" keyboardShortcut="CMD-C"/>
                             </buttonData>
                         </Menu.Item>
                         <Menu.Item action="paste">
                             <buttonData>
-                                <content:MenuItemData text="Paste" keyboardShortcut="CTRL-V"/>
+                                <content:MenuItemData text="Paste" keyboardShortcut="CMD-V"/>
                             </buttonData>
                         </Menu.Item>
                     </Menu.Section>

Modified: pivot/trunk/tutorials/www/menu-bars.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/menu-bars.xml?rev=1030093&r1=1030092&r2=1030093&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/menu-bars.xml (original)
+++ pivot/trunk/tutorials/www/menu-bars.xml Tue Nov  2 15:51:43 2010
@@ -72,11 +72,17 @@ limitations under the License.
 
         <p>
             The BXML source for this example is shown below. It creates the initial menu structure
-            as well as the tab pane that will host the simulated documents. Note that it also
-            defines a set of "action mappings" in the root frame's "actionMappings" sequence.
-            Action mappings associate keystrokes with actions; when a keystroke matching an action
-            in the sequence is processed by the window, the action is invoked. Action mappings are
-            often called "keyboard shortcuts".
+            as well as the tab pane that will host the simulated documents. It also defines a set
+            of "action mappings" in the root frame's "actionMappings" sequence. Action mappings
+            associate keystrokes with actions; when a keystroke matching an action in the sequence
+            is processed by the window, the action is invoked. Action mappings are often called
+            "keyboard shortcuts".
+        </p>
+
+        <p>
+            Note that the actions in this example are associated with the "CMD" key. This is a
+            Pivot-specific, platform-independent modifier. It maps to the Control key (CTRL)
+            on Windows and Linux and the Command key (META) on Mac OS X:
         </p>
 
         <source type="xml" location="org/apache/pivot/tutorials/menus/menu_bars.bxml">
@@ -92,9 +98,8 @@ limitations under the License.
                 </bxml:define>
 
                 <actionMappings>
-                    <Window.ActionMapping action="cut" keyStroke="CTRL-X"/>
-                    <Window.ActionMapping action="copy" keyStroke="CTRL-C"/>
-                    <Window.ActionMapping action="paste" keyStroke="CTRL-V"/>
+                    <Window.ActionMapping action="fileNew" keyStroke="CMD-N"/>
+                    <Window.ActionMapping action="fileOpen" keyStroke="CMD-O"/>
                 </actionMappings>
 
                 <menuBar>
@@ -102,8 +107,17 @@ limitations under the License.
                         <MenuBar.Item buttonData="File">
                             <Menu>
                                 <Menu.Section>
-                                    <Menu.Item buttonData="New" action="fileNew"/>
-                                    <Menu.Item buttonData="Open" action="fileOpen"/>
+                                    <Menu.Item action="fileNew">
+                                        <buttonData>
+                                            <content:MenuItemData text="New" keyboardShortcut="CMD-N"/>
+                                        </buttonData>
+                                    </Menu.Item>
+
+                                    <Menu.Item action="fileOpen">
+                                        <buttonData>
+                                            <content:MenuItemData text="Open" keyboardShortcut="CMD-O"/>
+                                        </buttonData>
+                                    </Menu.Item>
                                 </Menu.Section>
                             </Menu>
                         </MenuBar.Item>
@@ -113,17 +127,17 @@ limitations under the License.
                                 <Menu.Section>
                                     <Menu.Item action="cut">
                                         <buttonData>
-                                            <content:MenuItemData text="Cut" keyboardShortcut="CTRL-X"/>
+                                            <content:MenuItemData text="Cut" keyboardShortcut="CMD-X"/>
                                         </buttonData>
                                     </Menu.Item>
                                     <Menu.Item action="copy">
                                         <buttonData>
-                                            <content:MenuItemData text="Copy" keyboardShortcut="CTRL-C"/>
+                                            <content:MenuItemData text="Copy" keyboardShortcut="CMD-C"/>
                                         </buttonData>
                                     </Menu.Item>
                                     <Menu.Item action="paste">
                                         <buttonData>
-                                            <content:MenuItemData text="Paste" keyboardShortcut="CTRL-V"/>
+                                            <content:MenuItemData text="Paste" keyboardShortcut="CMD-V"/>
                                         </buttonData>
                                     </Menu.Item>
                                 </Menu.Section>

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java?rev=1030093&r1=1030092&r2=1030093&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Keyboard.java Tue Nov  2 15:51:43 2010
@@ -55,6 +55,8 @@ public final class Keyboard {
         private int keyCode = KeyCode.UNDEFINED;
         private int modifiers = 0x00;
 
+        public static final String COMMAND_ABBREVIATION = "CMD";
+
         public KeyStroke(int keyCode, int modifiers) {
             this.keyCode = keyCode;
             this.modifiers = modifiers;
@@ -127,7 +129,15 @@ public final class Keyboard {
             for (int i = 0, n = keys.length; i < n; i++) {
                 if (i < n - 1) {
                     // Modifier
-                    Modifier modifier = Modifier.valueOf(keys[i].toUpperCase(Locale.ENGLISH));
+                    String modifierAbbreviation = keys[i].toUpperCase(Locale.ENGLISH);
+
+                    Modifier modifier;
+                    if (modifierAbbreviation.equals(COMMAND_ABBREVIATION)) {
+                        modifier = Platform.getCommandModifier();
+                    } else {
+                        modifier = Modifier.valueOf(modifierAbbreviation);
+                    }
+
                     modifiers |= modifier.getMask();
                 } else {
                     // Keycode