Assume a Dialog named "Dialog1". To launch the Dialog when a tool is clicked, add the following lines to the tool's Click script:
theDialog = av.FindDialog("Dialog1") theDialog.OpenTo cause the Dialog to close when the View is closed or deactivated, add the following lines to its Open script:
theView = av.GetActiveDoc SELF.SetServer(theView) SELF.SetServerActivated("") SELF.SetServerClosed("CloseDialog") SELF.SetServerDeactivated("CloseDialog")where "CloseDialog" contains the following lines:
theDialog = av.FindDialog("Dialog1") theDialog.CloseTo cause the Dialog to close when the Tool is not selected, or reopen if the Tool is still selected when the View is reactivated, place the following lines at the beginning of the Tool's Update script:
theDialog = av.FindDialog("Dialog1") if (SELF.IsSelected) then theDialog.Open else theDialog.Close endUnfortunately, not every other tool causes an Update event when it's clicked. For every tool that lacks a Click script, assign one; even if the script is empty, it will automatically trigger an Update event.
SELF.GetControlPanel.SetEnabled(true)and the following in the Close script:
SELF.GetControlPanel.SetEnabled(false)
theView = av.GetActiveDoc SELF.SetServer(theView) SELF.SetServerActivated("Restore") SELF.SetServerClosed("Hide") SELF.SetServerDeactivated("Hide") SELF.SetObjectTag("NORESTORE")where "Hide" contains the following lines:
if (SELF.IsOpen) then SELF.SetObjectTag("RESTORE") SELF.Close endand "Restore" contains the following lines:
if (SELF.GetObjectTag = "RESTORE") then SELF.Open end