Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > InterfaceBuilder keyboard equiv

InterfaceBuilder keyboard equiv
Thread Tools
Dedicated MacNNer
Join Date: Nov 2000
Location: Malaysia
Status: Offline
Reply With Quote
Jul 9, 2002, 11:44 AM
 
I want to take a keyboard equiv for an NSButton in a nib. When I look at the NSButton Info box for attributes, you can see the "equiv" box. This can be set to a keystroke ("z" or "apple-9" or "opt-t") or to special keys. But these keys can only be Return/Delete/Escape/Tab.

I would like to trap ENTER specifically, but would probably also like to trap backspace or function keys. Is the only way to do this by subclassing NSWindow to get keyDown and then parse out what keys you want?

---gralem
     
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status: Offline
Reply With Quote
Jul 10, 2002, 04:46 PM
 
You can set the key equivalent programmatically in your controller's awakeFromNib method.

-(void)awakeFromNib
{
unichar keyEquiv = NSDeleteCharacter;
NSString *equivString = [NSString stringWithCharacters:&keyEquiv length:1];
[myButton setKeyEquivalent:equivString];
}

Look in NSEvent.h and NSText.h for list of unicode values for special characters like delete and the function keys.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:00 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2