Skip to content
Browse files

update for #205

  • Loading branch information...
1 parent 23f3379 commit a4358c8b84b6abbc9e9d88cc9a09074768fa0691 @keyemkey keyemkey committed Jul 5, 2013
View
64 awaybuilder-desktop/src/AwayBuilderApplication.mxml
@@ -11,20 +11,20 @@
preinitialize="preinitializeHandler(event)"
>
<s:menu>
- <mx:FlexNativeMenu dataProvider="{menuProvider}"/>
+ <mx:FlexNativeMenu dataProvider="{menuProvider}" keyEquivalentModifiersFunction="keyEquivalentModifiers"/>
</s:menu>
<fx:Declarations>
<fx:Array id="menuProvider">
<fx:Object label="File">
<fx:children>
<fx:Array>
- <fx:Object label="New" value="{EMenuItem.NEW_DOCUMENT}" keyEquivalent="n" controlKey="true"/>
- <fx:Object label="Open..." value="{EMenuItem.OPEN}" keyEquivalent="o" controlKey="true"/>
- <fx:Object label="Import..." value="{EMenuItem.IMPORT}" keyEquivalent="i" controlKey="true"/>
+ <fx:Object label="New" value="{EMenuItem.NEW_DOCUMENT}" keyEquivalent="n" modifyer="1" />
+ <fx:Object label="Open..." value="{EMenuItem.OPEN}" keyEquivalent="o" modifyer="1"/>
+ <fx:Object label="Import..." value="{EMenuItem.IMPORT}" keyEquivalent="i" modifyer="1"/>
<fx:Object type="separator"/>
- <fx:Object label="Save" value="{EMenuItem.SAVE}" keyEquivalent="s" controlKey="true"/>
- <fx:Object label="Save As..." value="{EMenuItem.SAVE_AS}" keyEquivalent="S" controlKey="true"/>
+ <fx:Object label="Save" value="{EMenuItem.SAVE}" keyEquivalent="s" modifyer="1"/>
+ <fx:Object label="Save As..." value="{EMenuItem.SAVE_AS}" keyEquivalent="S" modifyer="1"/>
<fx:Object type="separator"/>
<fx:Object label="Exit" value="{EMenuItem.EXIT}" />
</fx:Array>
@@ -33,16 +33,16 @@
<fx:Object label="Edit">
<fx:children>
<fx:Array>
- <fx:Object label="Undo" value="{EMenuItem.UNDO}" controlKey="true" keyEquivalent="z"/>
- <fx:Object label="Redo" value="{EMenuItem.REDO}" controlKey="true" keyEquivalent="y"/>
+ <fx:Object label="Undo" value="{EMenuItem.UNDO}" modifyer="1" keyEquivalent="z"/>
+ <fx:Object label="Redo" value="{EMenuItem.REDO}" modifyer="1" keyEquivalent="y"/>
<fx:Object type="separator"/>
- <fx:Object label="Cut" value="{EMenuItem.CUT}" controlKey="true" keyEquivalent="x"/>
- <fx:Object label="Copy" value="{EMenuItem.COPY}" controlKey="true" keyEquivalent="c"/>
- <fx:Object label="Paste" value="{EMenuItem.PASTE}" controlKey="true" keyEquivalent="v"/>
+ <fx:Object label="Cut" value="{EMenuItem.CUT}" modifyer="1" keyEquivalent="x"/>
+ <fx:Object label="Copy" value="{EMenuItem.COPY}" modifyer="1" keyEquivalent="c"/>
+ <fx:Object label="Paste" value="{EMenuItem.PASTE}" modifyer="1" keyEquivalent="v"/>
<fx:Object type="separator"/>
<fx:Object label="Delete" value="{EMenuItem.DELETE}"/>
<fx:Object type="separator"/>
- <fx:Object label="Select All" value="{EMenuItem.SELECT_ALL}" controlKey="true" keyEquivalent="a"/>
+ <fx:Object label="Select All" value="{EMenuItem.SELECT_ALL}" modifyer="1" keyEquivalent="a"/>
<fx:Object label="Select None" value="{EMenuItem.SELECT_NONE}"/>
<fx:Object type="separator"/>
<fx:Object label="Document Settings" value="{EMenuItem.DOCUMENT_SETTINGS}"/>
@@ -52,22 +52,22 @@
<fx:Object label="View">
<fx:children>
<fx:Array>
- <fx:Object label="Zoom In" value="{EMenuItem.ZOOM_IN}" controlKey="true" keyEquivalent="+"/>
- <fx:Object label="Zoom Out" value="{EMenuItem.ZOOM_OUT}" controlKey="true" keyEquivalent="-"/>
+ <fx:Object label="Zoom In" value="{EMenuItem.ZOOM_IN}" modifyer="1" keyEquivalent="+"/>
+ <fx:Object label="Zoom Out" value="{EMenuItem.ZOOM_OUT}" modifyer="1" keyEquivalent="-"/>
<fx:Object type="separator"/>
- <fx:Object label="Focus Selected" value="{EMenuItem.FOCUS}" controlKey="true" keyEquivalent="f"/>
+ <fx:Object label="Focus Selected" value="{EMenuItem.FOCUS}" modifyer="1" keyEquivalent="f"/>
</fx:Array>
</fx:children>
</fx:Object>
<fx:Object label="Tools">
<fx:children>
<fx:Array>
- <fx:Object label="Target Camera Mode" value="{EMenuItem.TARGET_CAMERA}" type="check" toggled="{true}" altKey="true" keyEquivalent="t"/>
- <fx:Object label="Free Camera Mode" value="{EMenuItem.FREE_CAMERA}" type="check" altKey="true" keyEquivalent="f"/>
+ <fx:Object label="Target Camera Mode" value="{EMenuItem.TARGET_CAMERA}" type="check" toggled="{true}" modifyer="2" keyEquivalent="t"/>
+ <fx:Object label="Free Camera Mode" value="{EMenuItem.FREE_CAMERA}" type="check" modifyer="2" keyEquivalent="f"/>
<fx:Object type="separator"/>
- <fx:Object label="Translate Transform Mode" value="{EMenuItem.TRANSLATE_MODE}" type="check" controlKey="true" keyEquivalent="t"/>
- <fx:Object label="Rotate Transform Mode" value="{EMenuItem.ROTATE_MODE}" type="check" controlKey="true" keyEquivalent="r"/>
- <fx:Object label="Scale Transform Mode" value="{EMenuItem.SCALE_MODE}" type="check" controlKey="true" keyEquivalent="s"/>
+ <fx:Object label="Translate Transform Mode" value="{EMenuItem.TRANSLATE_MODE}" type="check" modifyer="1" keyEquivalent="t"/>
+ <fx:Object label="Rotate Transform Mode" value="{EMenuItem.ROTATE_MODE}" type="check" modifyer="1" keyEquivalent="r"/>
+ <fx:Object label="Scale Transform Mode" value="{EMenuItem.SCALE_MODE}" type="check" modifyer="1" keyEquivalent="s"/>
</fx:Array>
</fx:children>
</fx:Object>
@@ -103,10 +103,14 @@
public var splashScreen:SplashScreen;
+ public var isMac:Boolean;
+
private function preinitializeHandler(event:FlexEvent):void
{
splashScreen = new SplashScreen();
+ isMac = (Capabilities.os.indexOf("Mac OS") >= 0);
+
_context = new DesktopAppContext(DisplayObjectContainer(this.systemManager));
var urlLoader:URLLoader = new URLLoader();
@@ -115,6 +119,26 @@
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, function(event:Event):void{ trace( event )} );
}
+ private function keyEquivalentModifiers(item:Object):Array
+ {
+
+ if( item.modifyer == "1" )
+ {
+ return [getCommandKey()];
+ }
+ else if( item.modifyer == "2" )
+ {
+ return [getCommandKey(),Keyboard.ALTERNATE];
+ }
+ return [];
+ }
+
+ public function getCommandKey():uint
+ {
+ if( isMac )
+ return Keyboard.COMMAND;
+ return Keyboard.CONTROL;
+ }
private function urlLoader_completeHandler( event:Event ):void
{
var urlLoader:URLLoader = event.target as URLLoader;
View
29 awaybuilder-desktop/src/awaybuilder/desktop/view/mediators/ApplicationMediator.as
@@ -16,8 +16,6 @@ package awaybuilder.desktop.view.mediators
import awaybuilder.model.vo.scene.AssetVO;
import awaybuilder.model.vo.scene.ObjectVO;
import awaybuilder.utils.enumerators.EMenuItem;
- import awaybuilder.utils.scene.CameraManager;
- import awaybuilder.utils.scene.Scene3DManager;
import awaybuilder.view.mediators.BaseApplicationMediator;
import flash.display.NativeMenuItem;
@@ -26,12 +24,12 @@ package awaybuilder.desktop.view.mediators
import flash.events.InvokeEvent;
import flash.events.KeyboardEvent;
import flash.filesystem.File;
+ import flash.system.Capabilities;
import flash.ui.Keyboard;
import flash.utils.Dictionary;
import mx.core.DragSource;
import mx.core.IIMESupport;
- import mx.events.AIREvent;
import mx.events.DragEvent;
import mx.events.FlexNativeMenuEvent;
import mx.managers.DragManager;
@@ -49,6 +47,9 @@ package awaybuilder.desktop.view.mediators
[Inject]
public var undoRedoModel:UndoRedoModel;
+ private var _isWin:Boolean;
+ private var _isMac:Boolean;
+
private var _menuCache:Dictionary;
override public function onRegister():void
@@ -94,23 +95,31 @@ package awaybuilder.desktop.view.mediators
getItemByValue( EMenuItem.CUT ).enabled = false;
getItemByValue( EMenuItem.COPY ).enabled = false;
getItemByValue( EMenuItem.PASTE ).enabled = false;
-// this.updateMenuEnabled();
+
+ _isWin = (Capabilities.os.indexOf("Windows") >= 0);
+ _isMac = (Capabilities.os.indexOf("Mac OS") >= 0);
+
+ if( _isMac )
+ {
+ getItemByValue( EMenuItem.EXIT ).keyEquivalent = "q";
+ getItemByValue( EMenuItem.EXIT ).keyEquivalentModifiers = [Keyboard.COMMAND];
+ }
}
private function focusInHandler(event:FocusEvent):void
{
const focus:IFocusManagerComponent = app.focusManager.getFocus();
if( focus is IIMESupport )
{
- getItemByValue( EMenuItem.CUT ).keyEquivalentModifiers = [Keyboard.ALTERNATE, Keyboard.CONTROL];
- getItemByValue( EMenuItem.COPY ).keyEquivalentModifiers = [Keyboard.ALTERNATE, Keyboard.CONTROL];
- getItemByValue( EMenuItem.PASTE ).keyEquivalentModifiers = [Keyboard.ALTERNATE, Keyboard.CONTROL];
+ getItemByValue( EMenuItem.CUT ).keyEquivalentModifiers = [Keyboard.ALTERNATE, app.getCommandKey()];
+ getItemByValue( EMenuItem.COPY ).keyEquivalentModifiers = [Keyboard.ALTERNATE, app.getCommandKey()];
+ getItemByValue( EMenuItem.PASTE ).keyEquivalentModifiers = [Keyboard.ALTERNATE, app.getCommandKey()];
}
else
{
- getItemByValue( EMenuItem.CUT ).keyEquivalentModifiers = [Keyboard.CONTROL];
- getItemByValue( EMenuItem.COPY ).keyEquivalentModifiers = [Keyboard.CONTROL];
- getItemByValue( EMenuItem.PASTE ).keyEquivalentModifiers = [Keyboard.CONTROL];
+ getItemByValue( EMenuItem.CUT ).keyEquivalentModifiers = [app.getCommandKey()];
+ getItemByValue( EMenuItem.COPY ).keyEquivalentModifiers = [app.getCommandKey()];
+ getItemByValue( EMenuItem.PASTE ).keyEquivalentModifiers = [app.getCommandKey()];
}
}

0 comments on commit a4358c8

Please sign in to comment.
Something went wrong with that request. Please try again.