vcl/osx/salnsmenu.mm |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

New commits:
commit 455dbe1a568b342f07fc0f07ba849ac813010304
Author: Maxim Monastirsky <momonas...@gmail.com>
Date:   Sun May 1 15:38:25 2016 +0300

    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 <c...@libreoffice.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm
index 6bbc683..f223b32 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() )
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to