summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-05-01 15:38:25 +0300
committerCaolán McNamara <caolanm@redhat.com>2016-05-19 14:47:29 +0000
commit455dbe1a568b342f07fc0f07ba849ac813010304 (patch)
tree7770851a7a55eccfdbbd8bad5ff45609bf39a93f
parent9aebda31e5310f2e4abd8409328bf6d22596ae77 (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 (cherry picked from commit 0975b5e4bdcd564b38b244589a44f5dd6cbdc63d) Reviewed-on: https://gerrit.libreoffice.org/24915 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/osx/salnsmenu.mm20
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm
index 6bbc683fc5ec..f223b3214b02 100644
--- a/vcl/osx/salnsmenu.mm
+++ b/vcl/osx/salnsmenu.mm
@@ -79,6 +79,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() )
{