Developer Developer - 2 months ago 6x
Objective-C Question

Set key equivalent to button programmatically

I want to set a key equivalent to a button in my app.

My code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[myButton setKeyEquivalent:@"D"];

- (IBAction)buttonPressed:(id)sender
NSLog(@"It worked!");

When I press
on the keyboard it doesn't do anything.
That's weird, because when I set the key equivalent in the xib it does work.
Does anyone know what to do to make it work?


Put in 'd' instead of 'D'.

[myButton setKeyEquivalent:@"d"];