Ethan
Ethan

Reputation: 18864

Unable to use Control key as the key equivalent for an NSButton in a xib file

I tried to use Control-Command-Whatever Alphabet as the key equivalent for an NSButton. Xcode interface builder doesn't allow me to do that. I tried editing the xib file in an external editor, adding control="YES" into the <modifierMask> node. Once I open the xib file in Xcode, Xcode deletes control="YES" that I added previously. The only workaround seems to be doing it in code.

Is there any reason Xcode disallows using Control in key equivalent for an NSButton? Should I also avoid doing it in code if it may become a problem?

I am using Xcode 6.1 on Yosemite.

Upvotes: 2

Views: 322

Answers (1)

matt
matt

Reputation: 535057

From the human interface guidelines:

As much as possible, avoid using the Control key. Because the Control key is already used by some of the universal access features—as well as in Cocoa text fields where Emacs-style key bindings are often used—it should be used as a modifier key only when necessary.

So, while the behavior of Xcode isn't very nice in this regard, it is probably just trying to enforce the guidelines. As you rightly say, you can work around it easily enough in code.

Upvotes: 1

Related Questions