Pregunta

I have Created Simple cocoa app. In which I use NSOutlineView. Now my task is to get the event of Escape Key pressed. In my appdelegate.m I implemented all require method for NSOutlineView.

¿Fue útil?

Solución

SubClass your NSOutlineView and capture its key down event as:

- (void)keyDown:(NSEvent *)theEvent
{       
    switch([theEvent keyCode]) 
    {
        case 53: // esc
            NSLog(@"ESC");
            // Implement the functionality you want when esc is pressed

            break;

        default:
           [super keyDown:theEvent];
    }
}

Otros consejos

Well you can find out the whther escape key was pressed or not try below one line and used in your method where it is required:-

NSUInteger flags = [theEvent keycode];
//After that 

If (flags==53)
{

NSlog(@"Escape key pressed");
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top