Reputation: 1272
I'm using things like CGEventSourceButtonState or CGEventSourceKeyState to detect input in my game.
I call them every frame to check if there was an event and so far it works fine.
I also check if the cursor is on top of the window or if the window is focused to know if I should ignore or not the input update
// check if window is focused
window.focused = nswindow.isKeyWindow;
// check if mouse is on_top of window
static bool cursor_on_top = false;
@interface Content_View : NSView
@end
@implementation Content_View
- (void)updateTrackingAreas {
[super updateTrackingAreas];
for (NSTrackingArea *tracking_area in [self trackingAreas]) {
[self removeTrackingArea:tracking_area];
}
NSTrackingAreaOptions options =
NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect;
NSTrackingArea *tracking_area = [[NSTrackingArea alloc]
initWithRect:self.bounds
options:options
owner:self
userInfo:nil
];
[self addTrackingArea:tracking_area];
}
- (void)mouseEntered:(NSEvent *)event {
cursor_on_top = true;
}
- (void)mouseExited:(NSEvent *)event {
cursor_on_top = false;
}
@end
The problem is that when I press command+shift+4 the system screenshot tool opens but that won't make window.focused
or cursor_on_top
false with the code above.
Because of this I get the events that are supposed to be for screenshot tool inside my game, since the left click will trigger camera movement.
It tried searching but there seems to not be a way of properly detecting if the screenshot tool has the input focus?
Upvotes: 0
Views: 37