Re: Close System Preferences programmatically
Re: Close System Preferences programmatically
- Subject: Re: Close System Preferences programmatically
- From: Murat Konar <email@hidden>
- Date: Tue, 4 Jan 2011 14:47:13 -0800
Leaving aside for the moment the wisdom of all this...
Preference panes run in the same process as the System Preferences application. That means they can directly call methods of the objects that make up System Preferences.
A simple way to get System Preferences to "Show All" is to simply call whatever object/method is targeted by the "Show All" menu item. Would work for "Quit" as well.
So you grab the menubar, scan the menu items until you find what you need, grab the target and action in said menu item, and just call it.
Now about the wisdom part: depending on what your definition of "uninstall" is, "Show All" may not get you what you need. For example, if "uninstall" means simply moving all your files to the trash or deleting them, that will not be enough. You will first have to get System Preferences to unload your bundle. That's not going to be very straightforward, unless you use your "force System Preferences to quit" strategy, which as mentioned already is not the best user experience.
_murat
On Jan 4, 2011, at 2:11 PM, Peter Lübke wrote:
> Though almost everybody seems to disagree you should do something like this here some ideas:
>
> - If you want to press the "Show All"- or "Back"- button, you could do this using the Accessibility API; take a look at Apple's "Accessibility Inspector" app.
>
> - If you really want System Preferences to quit, you could use NSAppleScript and do something like:
> tell application "System Preferences" to quit
> You can do the same using AppleEvents.
>
> If your app didn't open System Preferences programmatically before, I'd strongly suggest you ask the user if quitting is ok.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden