문제

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.

도움이 되었습니까?

해결책

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];
    }
}

다른 팁

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");
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top