Help with "New Document" - Tool Script
Posted: Sun Mar 23, 2014 8:50 am
I have made a Tool script that creates a New Document - mimicking File New (or Ctrl-N).
I like clicking New on toolbars, so I am trying to replicate that functionality via the Tool panel.
The script function itself is as simple as can be, and it works:
moho:FileNew()
However... I have a couple queries:
1. Function Placement
I am not sure of the correct place to utilise this function call. Currently I have it in "DoLayout(...)". I tried putting it in 'new(...)', 'Run(...)' and 'Handle Message::self.Create', but they don't appear to be invoked for this.
2. Switching off / Resetting the tool state
I only want the tool to be momentary. I have no need for the Options toolbar, and once it has run there is no further functionality (until I need another new document).
The tool is left selected after the new document is created, and it will run every time I switch tabs (i.e. return to the 1st document) or try to close the application.
So I created a boolean state flag to say that the NewDoc tool is active, which prevents unwanted re-running.
Ideally the tool would be able to switch back to the previous/default tool (similar to how the Insert Text tool does it, but that seemed to do it by magic), so that I can use it again later, or simply eliminate the need for the state flag above. But I and can't figure a way to reset the state or detect when another tool has been selected.
So.... Just wondering whether you had any thoughts?
Thanks
I like clicking New on toolbars, so I am trying to replicate that functionality via the Tool panel.
The script function itself is as simple as can be, and it works:
moho:FileNew()
However... I have a couple queries:
1. Function Placement
I am not sure of the correct place to utilise this function call. Currently I have it in "DoLayout(...)". I tried putting it in 'new(...)', 'Run(...)' and 'Handle Message::self.Create', but they don't appear to be invoked for this.
2. Switching off / Resetting the tool state
I only want the tool to be momentary. I have no need for the Options toolbar, and once it has run there is no further functionality (until I need another new document).
The tool is left selected after the new document is created, and it will run every time I switch tabs (i.e. return to the 1st document) or try to close the application.
So I created a boolean state flag to say that the NewDoc tool is active, which prevents unwanted re-running.
Ideally the tool would be able to switch back to the previous/default tool (similar to how the Insert Text tool does it, but that seemed to do it by magic), so that I can use it again later, or simply eliminate the need for the state flag above. But I and can't figure a way to reset the state or detect when another tool has been selected.
So.... Just wondering whether you had any thoughts?
Thanks