Developer Developer - 3 months ago 10
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
D
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?

Answer

Put in 'd' instead of 'D'.

[myButton setKeyEquivalent:@"d"];
Comments