vcl/source/window/menubarwindow.cxx | 19 ++++++++++++++----- vcl/source/window/menufloatingwindow.cxx | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-)
New commits: commit bb9c9fdd3d5f71ab49d3a5189af8e13ef5239f4a Author: Caolán McNamara <caol...@redhat.com> Date: Tue Aug 2 14:53:52 2016 +0100 gtk2: toggle menubar mnemonics on if any keyinput on it or submenus this is closer to how I seem to see the gtk menubars work (gtk3 is native now so this doesn't affect that) Change-Id: Ie5225d2ccda698946f26408aae95d2a50cbb928b diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index b2a5b80..812fff4 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -671,10 +671,10 @@ void MenuBarWindow::KeyInput( const KeyEvent& rKEvent ) bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) { - if( ! pMenu ) + if (!pMenu) return false; - if ( pMenu->bInCallback ) + if (pMenu->bInCallback) return true; // swallow bool bDone = false; @@ -808,6 +808,8 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) } bool accel = ImplGetSVData()->maNWFData.mbEnableAccel; + bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel; + if ( !bDone && ( bFromMenu || (rKEvent.GetKeyCode().IsMod2() && accel) ) ) { sal_Unicode nCharCode = rKEvent.GetCharCode(); @@ -818,14 +820,21 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) if ( pData && (nEntry != ITEMPOS_INVALID) ) { mbAutoPopup = true; - SetMBWMenuKey(true); - SetMBWHideAccel(true); - Invalidate(InvalidateFlags::Update); ChangeHighlightItem( nEntry, true ); bDone = true; } } } + + const bool bShowAccels = nCode != KEY_ESCAPE; + if (GetMBWMenuKey() != bShowAccels) + { + SetMBWMenuKey(bShowAccels); + SetMBWHideAccel(!bShowAccels); + if (accel && autoacc) + Invalidate(InvalidateFlags::Update); + } + return bDone; } diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index 6506704..66bb23d 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -976,6 +976,8 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent ) { VclPtr<vcl::Window> xWindow = this; + bool accel = ImplGetSVData()->maNWFData.mbEnableAccel; + bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel; sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode(); bKeyInput = true; switch ( nCode ) @@ -1102,7 +1104,7 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent ) sal_Unicode nCharCode = rKEvent.GetCharCode(); sal_uInt16 nPos = 0; sal_uInt16 nDuplicates = 0; - MenuItemData* pData = (nCharCode && pMenu) ? + MenuItemData* pData = (nCharCode && pMenu && accel) ? pMenu->GetItemList()->SearchItem(nCharCode, rKEvent.GetKeyCode(), nPos, nDuplicates, nHighlightedItem) : nullptr; if (pData) { @@ -1121,6 +1123,20 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent ) FloatingWindow::KeyInput( rKEvent ); } } + + if (pMenu && pMenu->pStartedFrom && pMenu->pStartedFrom->IsMenuBar()) + { + MenuBar *pMenuBar = static_cast<MenuBar*>(pMenu->pStartedFrom.get()); + const bool bShowAccels = nCode != KEY_ESCAPE; + if (pMenuBar->getMenuBarWindow()->GetMBWMenuKey() != bShowAccels) + { + pMenuBar->getMenuBarWindow()->SetMBWMenuKey(bShowAccels); + pMenuBar->getMenuBarWindow()->SetMBWHideAccel(!bShowAccels); + if (accel && autoacc) + Invalidate(InvalidateFlags::Update); + } + } + // #105474# check if menu window was not destroyed if ( !xWindow->IsDisposed() ) {
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits