[vlc-commits] macosx: change handling of arrow keys slightly

David Fuhrmann git at videolan.org
Tue Jul 3 13:52:16 CEST 2012


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Tue Jul  3 13:29:54 2012 +0200| [0ccbaa821f8b7b928c651df53db5ad50ed246b83] | committer: David Fuhrmann

macosx: change handling of arrow keys slightly

When the key is assigned to an main menu item: In this case the event
is never passed to the controls, so we want to handle it here for these
exeptional cases.

For all other cases: The event is ignored here and handled by the controls
(playlist, or video view, which also sends it to vlc core).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0ccbaa821f8b7b928c651df53db5ad50ed246b83
---

 modules/gui/macosx/MainWindow.m |    5 ++++-
 modules/gui/macosx/intf.h       |    2 +-
 modules/gui/macosx/intf.m       |    4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 6615cd1..61f0fa0 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -122,6 +122,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
 {
+    BOOL b_force = NO;
     // these are key events which should be handled by vlc core, but are attached to a main menu item
     if( ![self isEvent: o_event forKey: "key-vol-up"] &&
         ![self isEvent: o_event forKey: "key-vol-down"] &&
@@ -132,8 +133,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
         if([[NSApp mainMenu] performKeyEquivalent:o_event])
             return TRUE;
     }
+    else
+        b_force = YES;
 
-    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event] ||
+    return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
            [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
 }
 
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 61e0cae..9b0877b 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -175,7 +175,7 @@ struct intf_sys_t
 - (NSString *)localizedString:(const char *)psz;
 - (char *)delocalizeString:(NSString *)psz;
 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
 - (NSString *)VLCKeyToString:(NSString *)theString;
 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
 - (void)updateCurrentlyUsedHotkeys;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index ae2603e..fcc7cc5 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1315,7 +1315,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
  * shortcut key.  If it is, pass it off to VLC for handling and return YES,
  * otherwise ignore it and return NO (where it will get handled by Cocoa).
  *****************************************************************************/
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force
 {
     unichar key = 0;
     vlc_value_t val;
@@ -1346,7 +1346,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         return YES;
     }
 
-    if( val.i_int == 0 ) // ignore only when no modifier is pressed
+    if( !b_force )
     {
         switch( key )
         {



More information about the vlc-commits mailing list