Filter mouse events when dropdown open
authorRichard Fairhurst <richard@systemeD.net>
Tue, 11 Sep 2012 15:30:58 +0000 (16:30 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Tue, 11 Sep 2012 15:30:58 +0000 (16:30 +0100)
potlatch2.mxml

index 1fcdf25..806f66c 100644 (file)
             enabled="{MainUndoStack.getGlobalStack().canRedo()}"
             toolTip="{MainUndoStack.getGlobalStack().getRedoDescription() ? 'Redo '+MainUndoStack.getGlobalStack().getRedoDescription() : 'Redo last action'}" />
         <mx:Spacer width="100%"/>
-        <mx:PopUpButton id="bgButton" label="Background" openAlways="true" styleName="appBarButton"
+        <mx:PopUpButton id="bgButton" label="Background" openAlways="true" styleName="appBarButton" open="disableMapMouse();" close="enableMapMouse();" 
             creationComplete="bgButton.popUp = new BackgroundSelector();"/>
-        <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true" styleName="appBarButton"
+        <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true" styleName="appBarButton" open="disableMapMouse();" close="enableMapMouse();" 
             creationComplete="styleButton.popUp = new StyleSelector();"/>
-               <mx:PopUpMenuButton id="gpsButton" label="GPS" styleName="appBarButton"
+               <mx:PopUpMenuButton id="gpsButton" label="GPS" styleName="appBarButton" open="disableMapMouse();" close="enableMapMouse();" 
                    itemClick="if (event.index==0) { trackLoader.load(); } 
                          else if (event.index==1) { new MyGpxDialog().init(); } 
                                              else { mx.controls.Menu(gpsButton.popUp).selectedIndex=0; 
                private var spinner:Spinner;
                private var saveLabel:String='Save';
                private var saveTimer:Timer;
+               private var mouseTimer:Timer;
 
         include "version.as";
 
                        }
                }
 
+               private function disableMapMouse():void {
+                       map_area.mouseChildren=false;
+                       map_area.mouseEnabled=false;
+               }
+
+               private function enableMapMouse():void {
+                       mouseTimer=new Timer(300);
+                       mouseTimer.addEventListener(TimerEvent.TIMER, doEnable, false, 0, true);
+                       mouseTimer.start();
+               }
+               
+               private function doEnable(event:Event):void {
+                       map_area.mouseChildren=true;
+                       map_area.mouseEnabled=true;
+                       mouseTimer.removeEventListener(TimerEvent.TIMER, doEnable);
+                       mouseTimer=null;
+               }
+
         private function mouseoverHandler(e:MapEvent):void {
             if (coordsbox.visible) {
                 coordsbox.text= Number(e.params.x).toFixed(5) + "\n " + Number(e.params.y).toFixed(5); // Not sure if 5 dp's really required.