tdf#54169: do not hide mnemonics in menu, when navigating using mouse

Pressing Alt (or F10) by itself would activate/highlight the menu, and
show mnemonics. But clicking such activated menu used to disable the
mnemonics. This change fixes it, making sure that they keep displaying
until closing the menu.

Change-Id: I60f04e1474a8eb1322e5ac75f74b02d67dce9b73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163217
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-02-10 23:30:02 +06:00
parent 17fc445938
commit 7d59468721
2 changed files with 2 additions and 19 deletions

View file

@ -2861,13 +2861,6 @@ bool PopupMenu::PrepareRun(const VclPtr<vcl::Window>& pParentWin, tools::Rectang
if (!pSFrom && (vcl::IsInPopupMenuExecute() || !nItemCount)) if (!pSFrom && (vcl::IsInPopupMenuExecute() || !nItemCount))
return false; return false;
// 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())
{
auto pMenuBarWindow = static_cast<MenuBarWindow*>(pSFrom->pWindow.get());
pMenuBarWindow->SetMBWHideAccel( !(pMenuBarWindow->GetMBWMenuKey()) );
}
mpLayoutData.reset(); mpLayoutData.reset();
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();

View file

@ -465,7 +465,8 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
if( ! m_pMenu ) if( ! m_pMenu )
return; return;
SetMBWHideAccel(n == ITEMPOS_INVALID); if (n == ITEMPOS_INVALID)
SetMBWHideAccel(true);
// #57934# close active popup if applicable, as TH's background storage works. // #57934# close active popup if applicable, as TH's background storage works.
MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n ); MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n );
@ -850,8 +851,6 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
} }
} }
bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) ) if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) )
{ {
sal_Unicode nCharCode = rKEvent.GetCharCode(); sal_Unicode nCharCode = rKEvent.GetCharCode();
@ -868,15 +867,6 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
} }
} }
const bool bShowAccels = nCode != KEY_ESCAPE;
if (GetMBWMenuKey() != bShowAccels)
{
SetMBWMenuKey(bShowAccels);
SetMBWHideAccel(!bShowAccels);
if (autoacc)
Invalidate(InvalidateFlags::Update);
}
return bDone; return bDone;
} }