diff options
author | Simon Long <simon@raspberrypi.org> | 2015-07-08 18:02:50 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-07-09 15:07:24 +0000 |
commit | 74407aef94b6d8dfdd69891c4a6e578587ef3e71 (patch) | |
tree | cc8c8f9cde981f90760cb7fdaa02688713989f83 /vcl/source/window/menu.cxx | |
parent | 40ade8d04380083e383d6a6e50e5c254fcde2b2f (diff) |
tdf#92630 Enable auto-accelerator behaviour for gtk
Change-Id: I671177dd1f9e535c28a29bcbd6b74f1c789371ea
Reviewed-on: https://gerrit.libreoffice.org/16883
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/window/menu.cxx')
-rw-r--r-- | vcl/source/window/menu.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index cb836371d077..543f259f6cd9 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2022,6 +2022,12 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, aTmpPos.Y() += nTextOffsetY; DrawTextFlags nStyle = nTextStyle | DrawTextFlags::Mnemonic; + const Menu *pMenu = this; + while (!pMenu->IsMenuBar() && pMenu->pStartedFrom) + pMenu = pMenu->pStartedFrom; + if (pMenu->IsMenuBar() && (static_cast<MenuBarWindow*>(pMenu->pWindow.get()))->GetMBWHideAccel()) + nStyle |= DrawTextFlags::HideMnemonic; + if (pData->bIsTemporary) nStyle |= DrawTextFlags::Disable; MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; @@ -2602,6 +2608,37 @@ bool MenuBar::ImplHandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) return bDone; } +bool MenuBar::ImplHandleCmdEvent( const CommandEvent& rCEvent ) +{ + bool bDone = false; + const CommandModKeyData* pCData; + + // No keyboard processing when system handles the menu or our menubar is invisible + if( !IsDisplayable() || + ( ImplGetSalMenu() && ImplGetSalMenu()->VisibleMenuBar() ) ) + return bDone; + + // check for enabled, if this method is called from another window... + MenuBarWindow* pWin = static_cast<MenuBarWindow*>(ImplGetWindow()); + if ( pWin && pWin->IsEnabled() && pWin->IsInputEnabled() && ! pWin->IsInModalMode() ) + { + if (rCEvent.GetCommand() == CommandEventId::ModKeyChange) + { + pCData = rCEvent.GetModKeyData (); + if (pWin->nHighlightedItem == ITEMPOS_INVALID) + { + if (pCData && pCData->IsMod2()) + pWin->SetMBWHideAccel(false); + else + pWin->SetMBWHideAccel(true); + pWin->Invalidate(InvalidateFlags::Update); + } + return true; + } + } + return false; +} + void MenuBar::SelectItem(sal_uInt16 nId) { if (pWindow) @@ -2886,6 +2923,10 @@ sal_uInt16 PopupMenu::ImplExecute( vcl::Window* pW, const Rectangle& rRect, Floa if ( !pSFrom && ( PopupMenu::IsInExecute() || !GetItemCount() ) ) return 0; + // set the flag to hide or show accelerators in the menu depending on whether the menu was launched by mouse or keyboard shortcut + if( pSFrom && pSFrom->IsMenuBar()) + ((static_cast<MenuBarWindow*>(pSFrom->pWindow.get())))->SetMBWHideAccel(!(static_cast<MenuBarWindow*>(pSFrom->pWindow.get())->GetMBWMenuKey())); + delete mpLayoutData, mpLayoutData = NULL; ImplSVData* pSVData = ImplGetSVData(); |