Commit c97faddc authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed NSRangeException when triggering modifier keys without...

macosx: fixed NSRangeException when triggering modifier keys without characters as enabled by some international keyboards (close #7268)
parent 001a7f6e
......@@ -114,11 +114,15 @@ static VLCMainWindow *_o_sharedInstance = nil;
unsigned int i_keyModifiers = [[VLCMain sharedInstance] VLCModifiersToCocoa:o_key];
return [[[o_event charactersIgnoringModifiers] lowercaseString] isEqualToString: [[VLCMain sharedInstance] VLCKeyToString: o_key]] &&
NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0) {
return [[characters lowercaseString] isEqualToString: [[VLCMain sharedInstance] VLCKeyToString: o_key]] &&
(i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) &&
(i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) &&
(i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
(i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask);
}
return NO;
}
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
......
......@@ -142,7 +142,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( i_pressed_modifiers & NSCommandKeyMask )
val.i_int |= KEY_MODIFIER_COMMAND;
key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0];
NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
key = [[characters lowercaseString] characterAtIndex: 0];
if( key )
{
......@@ -151,7 +154,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( key == (unichar) 0x1b )
{
playlist_t * p_playlist = pl_Get( VLCIntf );
if( var_GetBool( p_playlist, "fullscreen" ) )
if( var_GetBool( p_playlist, "fullscreen") )
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
}
/* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
......@@ -174,8 +177,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if (p_vout)
vlc_object_release( p_vout );
return;
}
}
else
[super keyDown: o_event];
}
......
......@@ -345,7 +345,10 @@
- (BOOL)keyEvent:(NSEvent *)o_event
{
BOOL eventHandled = NO;
unichar key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0];
NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
unichar key = [characters characterAtIndex: 0];
if( key )
{
......@@ -375,6 +378,7 @@
vlc_object_release( p_input );
}
}
}
return eventHandled;
}
......
......@@ -1350,7 +1350,10 @@ unsigned int CocoaKeyToVLC( unichar i_key )
val.i_int |= KEY_MODIFIER_COMMAND;
}
key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0];
NSString * characters = [o_event charactersIgnoringModifiers];
if ([characters length] > 0)
{
key = [[characters lowercaseString] characterAtIndex: 0];
/* handle Lion's default key combo for fullscreen-toggle in addition to our own hotkeys */
if( key == 'f' && i_pressed_modifiers & NSControlKeyMask && i_pressed_modifiers & NSCommandKeyMask )
......@@ -1391,7 +1394,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
NSString *str = [o_usedHotkeys objectAtIndex: i];
unsigned int i_keyModifiers = [self VLCModifiersToCocoa: str];
if( [[[o_event charactersIgnoringModifiers] lowercaseString] isEqualToString: [self VLCKeyToString: str]] &&
if( [[characters lowercaseString] isEqualToString: [self VLCKeyToString: str]] &&
(i_keyModifiers & NSShiftKeyMask) == (i_pressed_modifiers & NSShiftKeyMask) &&
(i_keyModifiers & NSControlKeyMask) == (i_pressed_modifiers & NSControlKeyMask) &&
(i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) &&
......@@ -1407,6 +1410,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
var_SetInteger( p_intf->p_libvlc, "key-pressed", val.i_int );
return YES;
}
}
return NO;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment