cocoa,nsdocument,nswindowcontroller,nsevent,nsresponder
Yes, subclassing NSWindow is the way to do this if you need to get the keyboard event after everything up the responder chain refused to handle it. Here's how I did it in one of my projects: - (void)keyDown:(NSEvent*)event { SEL keyDownBool = @selector(keyDownBool:); if ([[self delegate] respondsToSelector:keyDownBool] && [[self...
You trap the corresponding mouseDown events import Cocoa class MyView : NSView { override func mouseDown(theEvent : NSEvent) { println("left mouse") } override func rightMouseDown(theEvent : NSEvent) { println("right mouse") } } See NSResponder for more magic....
objective-c,osx,nsview,osx-yosemite,nsevent
Found the issue. I had a NSTexField on the subview that was capturing the first mouseDown event. Just overlooked it.
swift,nsmenu,nsmenuitem,nsevent
You need to read the docu about NSRunLoop when your menu is displayed none of your threads will get control. Do you need to tell the OS you want to participate.
Put this in applicationDidFinishLaunching: NSUInteger modifiers = ([NSEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask); if (modifiers == NSAlternateKeyMask) { // do your sutff here } ...
You should be using locationInWindow, not mouseLocation. The docs on locationInWindow show how to go from there: NSPoint event_location = [theEvent locationInWindow]; NSPoint local_point = [self convertPoint:event_location fromView:nil]; ...