Determining if File is being closed
How do I determine if a MD File is being closed whilst my extension is active? If you open a different file all of the object references in the extension become invalid.
Regards
Mike
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Sean Reilly on 11 Jun, 2015 02:22 PM
Hi Mike,
Great question!
You can cast the FeatureModuleContext to com.moneydance.apps.md.controller.Main and then call mainObj.addAppEventListener(new com.moneydance.apps.md.controller.AppEventListener() {
public void handleEvent(String eventID) {
if("md:file:closing".equals(eventID)) {
// call some cleanup code here
}
}
});
Thanks,
Sean
2 Posted by Kevin Stembridg... on 11 Jun, 2015 09:50 PM
Hi chaps,
You can also override the handleEvent method in your Main class (I assume it extends FeatureModule) if that's an appropriate place for you to be notified.
Cheers,
Kevin
Support Staff 3 Posted by Sean Reilly on 11 Jun, 2015 10:39 PM
Ah yes, that is far better. Thanks Kevin!
4 Posted by Mike Bray (Quot... on 12 Jun, 2015 07:18 AM
Thanks Kevin and Sean
Kevin's answer made me look at FeatureModule in more detail and I saw the cleanUp() method. Would that do what I want, i.e. to know when to close my extension down?
Mike
5 Posted by Mike Bray (Quot... on 12 Jun, 2015 07:42 AM
Interesting, I have just done a test and put a breakpoint on the cleanup method. It was not called when I changed files.
Next test is Kevin's solution
6 Posted by Mike Bray (Quot... on 12 Jun, 2015 07:49 AM
That worked and all windows were closed. I will add this to my Wiki concerning extension writing.
Thanks for the help
Regards
Mike
Mike Bray (Quote Loader Author) closed this discussion on 13 Jun, 2015 04:57 AM.