From 74fd959945dbbfbc3dcc331a08ff8fc7c6410295 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Wed, 14 Sep 2016 02:02:38 +0300 Subject: tdf#74377 Keyboard shortcuts for context menus Configurable through the options dialog. The default behavior depends on the current vclplug (hide for gtk2/3 and OS X, show otherwise). Menus currently affected by this change: - SfxDispatcher based context menus - chart2 context menus - vcl's Edit control context menu - Several MenuBarManager based toolbar dropdowns. Change-Id: Iad9fb99dc90e01c17cba9c07c1a2b262b920e11d Reviewed-on: https://gerrit.libreoffice.org/28849 Reviewed-by: Maxim Monastirsky Tested-by: Maxim Monastirsky --- framework/source/uielement/menubarmanager.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'framework') diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 8e1f55917dc0..a7ed57273b88 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -746,6 +746,7 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool ) bool bDontHide = SvtMenuOptions().IsEntryHidingEnabled(); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); bool bShowMenuImages = rSettings.GetUseImagesInMenus(); + bool bShowShortcuts = m_bHasMenuBar || rSettings.GetContextMenuShortcuts(); bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED ); SolarMutexGuard g; @@ -794,18 +795,23 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool ) } // Try to set accelerator keys - if ( m_bHasMenuBar ) { - RetrieveShortcuts( m_aMenuItemHandlerVector ); + if ( bShowShortcuts ) + RetrieveShortcuts( m_aMenuItemHandlerVector ); + std::vector< MenuItemHandler* >::iterator p; for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p ) { MenuItemHandler* pMenuItemHandler = *p; - // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex - // Only non-popup menu items can have a short-cut - if ( pMenuItemHandler->aMenuItemURL == aCmdHelpIndex ) + if ( !bShowShortcuts ) + { + pMenu->SetAccelKey( pMenuItemHandler->nItemId, vcl::KeyCode() ); + } + else if ( pMenuItemHandler->aMenuItemURL == aCmdHelpIndex ) { + // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex + // Only non-popup menu items can have a short-cut vcl::KeyCode aKeyCode( KEY_F1 ); pMenu->SetAccelKey( pMenuItemHandler->nItemId, aKeyCode ); } -- cgit