nsevent

Mouse Events Bleeding Through NSView

守給你的承諾、 提交于 2020-01-13 09:57:07
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

Mouse Events Bleeding Through NSView

▼魔方 西西 提交于 2020-01-13 09:57:06
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

How to pass scroll events to parent NSScrollView

假装没事ソ 提交于 2020-01-12 16:50:47
问题 I need fixed-size NSTextViews inside a larger scrolling window. IB requires that the textviews be inside their own NSScrollViews, even though their min/max sizes are fixed so that they won’t actually scroll. When trackpad gestures are made within the textview frames (regardless of whether they have focus), they are captured by the textviews’ scrollviews, so nothing happens. How do I tell the textviews’ scrollviews to pass scroll events up to the window’s main scrollview? (Or perhaps I should

How to pass scroll events to parent NSScrollView

﹥>﹥吖頭↗ 提交于 2020-01-12 16:50:09
问题 I need fixed-size NSTextViews inside a larger scrolling window. IB requires that the textviews be inside their own NSScrollViews, even though their min/max sizes are fixed so that they won’t actually scroll. When trackpad gestures are made within the textview frames (regardless of whether they have focus), they are captured by the textviews’ scrollviews, so nothing happens. How do I tell the textviews’ scrollviews to pass scroll events up to the window’s main scrollview? (Or perhaps I should

Detecting Ctrl + Return or Ctrl + Enter presses

风流意气都作罢 提交于 2020-01-04 06:48:33
问题 I find it very hard to find anything official on this matter. I have a TextView and override the keyDown event and try to detect if the user pressed Ctrl + Enter . - (void)keyDown:(NSEvent *)theEvent { if([theEvent modifierFlags] & NSControlKeyMask && /* how to check if enter is pressed??? */) { NSLog(@"keyDown: ctrl+enter"); if(_delegate) { if([_delegate respondsToSelector:@selector(didSomething:)]) { [_delegate performSelector:@selector(didSomething:) withObject:nil]; } } }else { [super

macOS App: handling key combinations bound to global keyboard shortcuts

眉间皱痕 提交于 2019-12-31 23:41:12
问题 In some apps, it makes sense for the app to directly handle keyboard shortcuts which are otherwise bound to system wide combinations. For example, ⌘-Space (normally Spotlight) or ⌘-Tab (normally app switcher). This works in various Mac apps, such as VMWare Fusion, Apple's own Screen Sharing and Remote Desktop clients (forwarding the events to the VM or server, respectively, instead of handling them locally), and also some similar third-party apps in the App Store. We would like to implement

Is there a way to differentiate between left and right Shift keys being pressed?

爱⌒轻易说出口 提交于 2019-12-29 07:35:13
问题 I can recognize when the user presses any Shift key with this code: -(void)flagsChanged:(NSEvent *)theEvent { if ([theEvent modifierFlags] & NSShiftKeyMask) //. . . } but is there any way to distinguish whether it was the right or left Shift key that was pressed? 回答1: You can do it like this: -(void)flagsChanged:(NSEvent *)theEvent { if ([theEvent modifierFlags] == 131330) { NSLog(@"Left shift pressed!"); } if ([theEvent modifierFlags] == 131332) { NSLog(@"Right shift pressed!"); } } 回答2: In

check whether mouse was clicked inside NSTableView

江枫思渺然 提交于 2019-12-25 04:29:21
问题 I have some mouse click-checking code in a NSTableView subclass that can intercept and modify mouse events to allow for clicking of buttons inside the table but the problem is that these events are also intercepted if the mouse is clicked anywhere else, not just on the table. My question therefore: How can I check if NSPoint.locationInWindow is within ONLY the table's visible bounds? My code below lets the event through even if clicked somewhere where a table row is scrolled beyond the

NSOpenGLView, NSWindow & NSResponder - makeFirstResponder not working

℡╲_俬逩灬. 提交于 2019-12-23 13:00:17
问题 In the code below I am Initialising a NSViewController [a NSResponder], with a NSWindow , a NSOpenGLView , presenting the view and attempting to set the NSViewController as the windows first responder. It is not working. I was expecting to be able to hit a breakpoint in the keyUp: and keyDown: methods also below, but nothing is happening. Am I missing something? -(void)initwithFrame:(CGRect)frame { window = [[MyNSWindow alloc] initWithContentRect:frame styleMask:NSClosableWindowMask |

Register a global hotkey without support for assistive devices enabled

≯℡__Kan透↙ 提交于 2019-12-22 21:59:17
问题 Using this code, I may register a global event handler: [NSEvent addGlobalMonitorForEventsMatchingMask: NSKeyDownMask handler: ^(NSEvent *incomingEvent) { NSString *chars = [[incomingEvent characters] lowercaseString]; unichar character = [chars characterAtIndex:0]; // do something useful NSLog(@"keydown globally! Which key? This key: %c", character); }]; Unfortunately, events get passed along to this monitor, if support for assistive devices is enabled. Without assistive devices being