Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically determine if "Full Keyboard Access" mode is on in MacOS?

Full Keyboard Access mode is enabled or disabled in the Keyboard preference pane - it's referenced here:

Efficiently subclassing standard Cocoa controls

and here:

Disable Full Keyboard Access for App

but nowhere on the web have I found out how to determine, within my app, if Full Keyboard Access is enabled. I'm writing a custom radio control and want to allow tabbing into it iff Full Keyboard Access is on.

like image 949
Mira Avatar asked Jul 10 '11 21:07

Mira


2 Answers

In Mac OS X 10.6 or higher: -[NSApp isFullKeyboardAccessEnabled].

like image 157
danielpunkass Avatar answered Sep 25 '22 21:09

danielpunkass


As best I know this is undocumented. It is stored in AppleKeyboardUIMode in NSGlobalDomain:

defaults read -g AppleKeyboardUIMode

It's a bitfield, but I've never seen docs for it. "Full Keyboard Access" seems to toggle bit 1 (value=2).

The short is you should be able to fetch this from NSUserDefaults and bitmask it to find your answer, but it could change.

like image 24
Rob Napier Avatar answered Sep 23 '22 21:09

Rob Napier