better Save button detection
[potlatch2.git] / potlatch2.mxml
index f878b7caac2171945de43e927500638ee088f682..9aa18c68810b40ee1f87d66e83a8e5bc7f8e0567 100755 (executable)
@@ -35,8 +35,8 @@
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" />
         <mx:Button label="Options" click="new OptionsDialog().init();" /> 
-        <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"
-                       enabled="{MainUndoStack.getGlobalStack().canUndo()}"/>
+        <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();" id="saveButton" 
+                       enabled="false"/>
     </mx:ApplicationControlBar>
     
     <mx:HDividedBox width="100%" height="100%">
             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
             conn.addEventListener(Connection.SAVE_STARTED, onDataStart);
             conn.addEventListener(Connection.SAVE_COMPLETED, onDataComplete);
+            conn.addEventListener(Connection.DATA_DIRTY, onDataDirty);
+            conn.addEventListener(Connection.DATA_CLEAN, onDataClean);
                }
                
         public function onResizeMap():void {
                        else                            { dataWorking.text=""; }
                        dataWorking.visible=(dataWorking.text!="");
                }
-        
+        private function onDataDirty(event:Event):void {
+                       saveButton.enabled=true;
+               }
+               private function onDataClean(event:Event):void {
+                       saveButton.enabled=false;
+               }
+               
         private function onImageryLoad(event:Event):void {
                        var xml:XML = new XML(URLLoader(event.target).data);
             theController.imagery=new Array(