shutdown script

Next
 From:  pressure (PEER)
11180.1 
Is there a way to run a script at shutdown, kind of like how scripts in the startup folder get run when an instance of MoI starts?

Also, how can I prevent PromptSaveChanges from getting shown at shutdown so that I can show my own modified version instead? I'm trying to avoid directly editing PromptSaveChanges.htm so that I don't have problems with version updates and such.

I guess I could prevent PromptSaveChanges from being shown if I could make sure that my shutdown script runs prior to whatever machinery decides whether to show PromptSaveChanges. For the thing I'm working on it would be fine for my shutdown script to save the currently open file so that moi.geometryDatabase.currentFileChanged is false, which seems to prevent PromptSaveChanges from getting shown.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11180.2 In reply to 11180.1 
Hi Peer, sorry no there isn't any mechanism currently set up for a script to be run at shutdown time.

One way to avoid PromptSaveChanges from being shown is to all moi.exit( true /* NoQuerySaveChanges */ );

or also another way is if you clear the current content using moi.geometryDatabase.fileNew( true /* NoQuerySaveChanges */ );

Otherwise the way that PromptSaveChanges will be shown is when the last saved revision number is smaller than the current geometry database revision number.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
11180.3 In reply to 11180.2 
Hi Michael,

Thanks for the tips about NoQuerySaveChanges and for the specifics on when PromptSaveChanges is shown.

That's a shame about not being able to run a script at shutdown since it seems like the X on the window for closing the window and also "Quit Moi" (on macOS) are outside of the html environment and so it's not like I can hook up script to them like html buttons.

I guess I'll have to add a Quit button somewhere and be careful to not use those other buttons that I'd normally go for and also be careful to not do cmd-Q. Unless you have any other ideas about how I can ensure that quitting always goes through a script.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11180.4 In reply to 11180.3 
Hi Peer,

re:
> Unless you have any other ideas about how I can ensure that quitting always goes through a script.

Sorry no there isn't any way that I'm aware of that would enable a script to take control of program shutdown.

In addition to window close button or Cmd+Q it can also be triggered by user logout or OS shutdown.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  pressure (PEER)
11180.5 In reply to 11180.4 
Hi Michael,

Thanks for explaining what causes PromptSaveChanges to get shown. I was able to get the behavior I want by doing this:

code:
// force PromptSaveChanges to be shown when MoI exits
moi.geometryDatabase.incrementRevision();
moi.geometryDatabase.setUserText('dummy', 'dummy');


- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All