diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2016-05-01 15:38:25 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-05-01 16:16:50 +0300 |
commit | 0975b5e4bdcd564b38b244589a44f5dd6cbdc63d (patch) | |
tree | ef56be2c7f11465f1819dd78573df5d950c1a301 /vcl/osx | |
parent | 7fb97f25d16bd65fe8d32ca12c8b7acc89500991 (diff) |
tdf#49853 Some shortcuts should always end up in the view
... because they are also used internally by vcl controls,
so we want let those controls handle them when they are
focused.
[VCL_NSApplication sendEvent] is more natural place for
this probably, but doing it there we'll lose the "blinking"
effect of the menu bar, even when the focus is in the
document area. So try harder, and handle it inside the menu
code. If this will create any trouble, we can always switch
to the simpler solution.
Change-Id: I827ab0585aabe1ed53fc31c5b8e1dddadef3361d
Diffstat (limited to 'vcl/osx')
-rw-r--r-- | vcl/osx/salnsmenu.mm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm index a0de415c0cd4..76aee7a6c032 100644 --- a/vcl/osx/salnsmenu.mm +++ b/vcl/osx/salnsmenu.mm @@ -94,6 +94,26 @@ (void)aSender; SolarMutexGuard aGuard; + // tdf#49853 Keyboard shortcuts are also handled by the menu bar, but at least some of them + // must still end up in the view. This is necessary to handle common edit actions in docked + // windows (e.g. in toolbar fields). + NSEvent* pEvent = [NSApp currentEvent]; + if( pEvent && [pEvent type] == NSKeyDown ) + { + unsigned int nModMask = ([pEvent modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)); + NSString* charactersIgnoringModifiers = [pEvent charactersIgnoringModifiers]; + if( nModMask == NSCommandKeyMask && + ( [charactersIgnoringModifiers isEqualToString: @"v"] || + [charactersIgnoringModifiers isEqualToString: @"c"] || + [charactersIgnoringModifiers isEqualToString: @"x"] || + [charactersIgnoringModifiers isEqualToString: @"a"] || + [charactersIgnoringModifiers isEqualToString: @"z"] ) ) + { + [[[NSApp keyWindow] contentView] keyDown: pEvent]; + return; + } + } + const AquaSalFrame* pFrame = mpMenuItem->mpParentMenu ? mpMenuItem->mpParentMenu->getFrame() : nullptr; if( pFrame && AquaSalFrame::isAlive( pFrame ) && ! pFrame->GetWindow()->IsInModalMode() ) { |