Search code examples
macoscocoakeyboardxcode5.1

Enable "Full Keyboard Access" programmatically on OS X


I'm developing an app for Mac OS X with Xcode 5 and I need to navigate through the buttons, radio buttons with the Tab key.

There's a way for navigate between buttons and all other controls by enabling this option in System Preferences:

enter image description here

…but I need to enable this programmatically for new users which doesn't have this feature enabled. How do I do that?


Solution

  • You can find out where the preference is stored on disk and change that file, but that is not a good idea. What if the user does not want Tab to cycle through all controls? And the implementation will be fragile: what if Apple changes the name of the plist key in a future release?

    A better way is to use the OS X Accessibility API so that your app can access the user interface of other apps. (For security reasons, your app needs to prompt the user to enable accessibility through System Preferences.)