winemac: Add a category on NSEvent to simplify checking if the Command key (and only that modifier) is pressed for an event.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2017-04-24 13:07:09 -05:00 committed by Alexandre Julliard
parent 04317b5571
commit af2690ab06
3 changed files with 27 additions and 1 deletions

View File

@ -1653,7 +1653,7 @@ - (void) handleMouseButton:(NSEvent*)theEvent
if ([window isKindOfClass:[WineWindow class]] && if ([window isKindOfClass:[WineWindow class]] &&
type == NSLeftMouseDown && type == NSLeftMouseDown &&
(([theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask| NSAlternateKeyMask | NSCommandKeyMask)) != NSCommandKeyMask)) ![theEvent wine_commandKeyDown])
{ {
NSWindowButton windowButton; NSWindowButton windowButton;

View File

@ -28,6 +28,12 @@
}; };
@interface NSEvent (WineExtensions)
+ (BOOL) wine_commandKeyDown;
- (BOOL) wine_commandKeyDown;
@end
@class WineWindow; @class WineWindow;

View File

@ -40,6 +40,26 @@
static const OSType WineHotKeySignature = 'Wine'; static const OSType WineHotKeySignature = 'Wine';
@implementation NSEvent (WineExtensions)
static BOOL wine_commandKeyDown(NSUInteger flags)
{
return ((flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) == NSCommandKeyMask);
}
+ (BOOL) wine_commandKeyDown
{
return wine_commandKeyDown([self modifierFlags]);
}
- (BOOL) wine_commandKeyDown
{
return wine_commandKeyDown([self modifierFlags]);
}
@end
@interface MacDrvEvent : NSObject @interface MacDrvEvent : NSObject
{ {
@public @public