
// Script function: Script for graying out (disabling) the dialog and saving input settings as default after clicking "Click Me".
// The dialog is grayed out after clicking the "Click Me" button. The last input for Item One is not saved after clicking the button, while the last inputs for Item Two and Item Three are saved as default.

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html



Class GlobalSionDialog : UIFrame
  {       
    void EMReset(object EMObject, number MyDisable)
     {                                                             
         EMObject.SetElementIsEnabled("EMDisableOne", MyDisable)                                                           
         EMObject.SetElementIsEnabled("EMDisableTwo", MyDisable)
         EMObject.SetElementIsEnabled("EMDisableThree", MyDisable)
         EMObject.SetElementIsEnabled("EMDisableFive", MyDisable)
     } 
 
     void EMPushButton(object EMObject)
     {                                               
         EMObject.EMReset(0)  
           
         image EMImage 
         taggroup EMTags=ImageGetTagGroup(EMImage) 
         
         EMObject.EMReset(1)
         return
      }
 
 
     void EMSaveChanges(object EMObject, TagGroup XXX) 
      {
         number EMNumberTwo=DLGGetValue(EMObject.LookupElement("EMDisableTwo")) 
         SetPersistentNumberNote("GlobalSino Saved Value: EMA",EMNumberTwo) // Save the changed values as defaults
                                                             
         number EMNumberThree=DLGGetValue(EMObject.LookupElement("EMDisableFive"))
         SetPersistentNumberNote("GlobalSino Saved Value: EMB",EMNumberThree) // Save the changed values as defaults
                                                               
      }  
 
TagGroup GlobalSinoUserInterface( object EMObject ) 
      {
         TagGroup EMDialog = DLGCreateDialog("GlobalSino Test Dialog")                            
         TagGroup GlobalSinoBoxOne
         TagGroup GlobalSinoBoxOneA=DLGCreateBox("Box One",GlobalSinoBoxOne)
         
         TagGroup  EMDisableTagOne// ============================
         number EMBoxNumberOne
         TagGroup EMLabel=DLGCreateLabel("Item One")
 
         EMDisableTagOne=DLGCreateRealField(EMBoxNumberOne, 8,4).DLGIdentifier("EMDisableOne").DLGChangedMethod("EMSaveChanges")
         TagGroup EMBoxOneGroup= DLGGroupItems(EMLabel, EMDisableTagOne)
                                
         TagGroup EMPopupIems
         EMLabel=DLGCreateLabel("Item Two")
                                
         number EMEntryOne
         GetPersistentNumberNote("GlobalSino Saved Value: EMB", EMEntryOne) // Save the changed values as defaults
                                 
         TagGroup EMItemsTwo=DLGCreatePopup(EMPopupIems,EMEntryOne).DLGIdentifier("EMDisableFive").DLGChangedMethod("EMSaveChanges") 
         EMPopupIems.DLGAddPopupItemEntry("X 1")
         EMPopupIems.DLGAddPopupItemEntry("X 2")
         EMPopupIems.DLGAddPopupItemEntry("X 3")
         TagGroup EMBoxTwoGroup=DLGGroupItems(EMLabel,EMItemsTwo)
 
         TagGroup EMTopGroup=DLGGroupItems(EMBoxOneGroup,EMBoxTwoGroup)
         GlobalSinoBoxOne.DLGAddElement(EMTopGroup)
         EMDialog.DLGAddElement(GlobalSinoBoxOneA)
 
         TagGroup EMInputItems
         TagGroup GlobalSinoBoxTwo=DLGCreateBox("Box Two",EMInputItems)
         TagGroup EMButton=DLGCreatePushButton("Free Button", "").DLGIdentifier("EMDisableThree")
          
         TagGroup EMDisableTagTwo
         EMLabel=DLGCreateLabel("Item Three")
         number EMEntryTwo
         GetPersistentNumberNote("GlobalSino Saved Value: EMA",EMEntryTwo)
         EMDisableTagTwo=DLGCreateRealField(EMEntryTwo, 8,4).DLGIdentifier("EMDisableTwo").DLGChangedMethod("EMSaveChanges")
         TagGroup EMTagGroupTwo=DLGGroupItems(EMLabel, EMDisableTagTwo)                        
         TagGroup GlobalSinoBoxTwoA =DLGGroupItems(EMButton, EMTagGroupTwo)
         EMInputItems.DLGAddElement(GlobalSinoBoxTwoA)
         EMDialog.DLGAddElement(GlobalSinoBoxTwo)
 
         TagGroup GlobalSinoPushButton=DLGCreatePushButton("Click Me","EMPushButton")                              
         EMDialog.DLGAddElement(GlobalSinoPushButton)         
         return EMDialog
                }                        
 
GlobalSionDialog ( object EMObject )
       {
        EMObject.init( EMObject.GlobalSinoUserInterface() )
       }
}
              
 if ( alloc( GlobalSionDialog).Pose() ) exit (0)