PreferenceModule is hidden

7 views
Skip to first unread message

Fabian Jäger

unread,
Aug 9, 2013, 12:45:46 PM8/9/13
to apple-m...@googlegroups.com
Dear Mail experts,
is there a method that gets called when a PreferenceModule is hidden, meaning that another PreferenceModule is selected by the user?
I would like to save changes made to my plugin's preferences when the user leaves those preferences.

Best regards,
Fabian

Adam Nohejl

unread,
Aug 10, 2013, 3:36:18 AM8/10/13
to apple-m...@googlegroups.com
Hi Fabian,

I think that there is a mechanism explicitly designed to check if changes are saved. (You can find out by tracking what happens if there are unsaved changes in the account preferences.)

I do something simpler, though, to detect if the preference module is switched from. If you also want to handle the case when the whole window is closed (which I do not handle), removing the [[self window] isVisible] part should work.

So this is what I do: I have my settings displayed in a NSBox subclass that implements this method:

- (void) viewWillMoveToSuperview: (NSView*) newSuperview{
if( newSuperview == nil && [[self window] isVisible] ){
// do stuff
}
}

--
Adam

Fabian Jäger

unread,
Aug 10, 2013, 12:40:20 PM8/10/13
to apple-m...@googlegroups.com
Dear Adam,
thanks a look. The described approach works like a charm!

Best regards,
Fabian
> --
> You received this message because you are subscribed to the Google Groups "Apple Mail Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to apple-mail-de...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

Reply all
Reply to author
Forward
0 new messages