Pregunta

I would like to be able to use the tableview in my NSWindowController using only keys. The up and down keys already work so all I need is the enter key for selecting. I do this using the keyUp method in my NSWindowController:

- (void)keyUp:(NSEvent *)the Event {
    if (theEvent.keyCode == 36) // Enter key
         // Do stuff
}

It works fine, the only problem is that whenever I press enter the computer plays a system sound. Does anyone know how I could mute the sound, or maybe another way to do this?

¿Fue útil?

Solución

You have to call [super keyUp:theEvent]; as default

Otros consejos

Okay so here's what I did to silence the sound for anyone who wants to know. Create a custom class for your view and override this method:

- (BOOL)performKeyEquivalent:(NSEvent *)theEvent {
    [super performKeyEquivalent:theEvent];
    return YES;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top