[Libreoffice-commits] core.git: vcl/osx

Maxim Monastirsky momonasmon at gmail.com
Sun May 1 13:18:48 UTC 2016


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

New commits:
commit 0975b5e4bdcd564b38b244589a44f5dd6cbdc63d
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

diff --git a/vcl/osx/salnsmenu.mm b/vcl/osx/salnsmenu.mm
index a0de415..76aee7a 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() )
     {


More information about the Libreoffice-commits mailing list