summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-02 14:53:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-02 14:56:42 +0100
commitbb9c9fdd3d5f71ab49d3a5189af8e13ef5239f4a (patch)
tree6e4f72d8872c170730451122eb620021a884ac96 /vcl
parent4e9bd1bc07e82810fba9c29ac7ee3e31ed4eec44 (diff)
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
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menubarwindow.cxx19
-rw-r--r--vcl/source/window/menufloatingwindow.cxx18
2 files changed, 31 insertions, 6 deletions
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index b2a5b808f534..812fff476862 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 6506704da53a..66bb23d447ea 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() )
{