[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - vcl/osx

Maxim Monastirsky momonasmon at gmail.com
Thu May 19 14:47:49 UTC 2016


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

New commits:
commit 455dbe1a568b342f07fc0f07ba849ac813010304
Author: Maxim Monastirsky <momonasmon at 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 <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at 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() )
     {


More information about the Libreoffice-commits mailing list