Kaydet (Commit) bb9c9fdd authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst 4e9bd1bc
......@@ -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;
}
......
......@@ -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() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment