From 40cfc19fed318a97ed030ad2729a6fbae992c8ef Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 30 Sep 2019 20:39:28 -0700 Subject: MacOS app: using Command+f or Command+Enter to toggle fullscreen mode instead of just 'f' --- .../Apple/Source/Classes/OSX/WindowController.m | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/Common/NativeApp/Apple/Source/Classes/OSX/WindowController.m b/Common/NativeApp/Apple/Source/Classes/OSX/WindowController.m index b908c1b..e3f7923 100644 --- a/Common/NativeApp/Apple/Source/Classes/OSX/WindowController.m +++ b/Common/NativeApp/Apple/Source/Classes/OSX/WindowController.m @@ -21,6 +21,9 @@ @end @implementation WindowController +{ + bool CommandKeyPressed; +} - (instancetype)initWithWindow:(NSWindow *)window { @@ -32,6 +35,8 @@ _fullscreenWindow = nil; } + CommandKeyPressed = false; + return self; } @@ -141,16 +146,21 @@ [self goWindow]; } return; - // Have f key toggle fullscreen + + // Have Command+f or Command+Enter toggle fullscreen + case 13: case 'f': - if([self fullscreenWindow] == nil) - { - [self goFullscreen]; - } - else - { - [self goWindow]; - } + if (CommandKeyPressed) + { + if([self fullscreenWindow] == nil) + { + [self goFullscreen]; + } + else + { + [self goWindow]; + } + } return; } @@ -158,4 +168,14 @@ //[super keyDown:event]; } +// Informs the receiver that the user has pressed or released a +// modifier key (Shift, Control, and so on) +- (void)flagsChanged:(NSEvent *)event +{ + auto modifierFlags = [event modifierFlags]; + CommandKeyPressed = modifierFlags & NSEventModifierFlagCommand; + + [super flagsChanged:event]; +} + @end -- cgit v1.2.3