From aaefd2080ecb39a3deade23368a83acee91367ef Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 22 Dec 2023 09:25:53 +0100 Subject: tdf#157649 Allow omitting Alt key when focus is in dialog action area Adapt to usual Windows experience: Allow triggering the Ok, Cancel, etc buttons in the dialog action area without pressing the Alt key - when the focus is in that area (and the accelerator is unique in that dialog). Change-Id: I85b544867cf5507a15240b2972a26a1c248c4f82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161146 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt (cherry picked from commit ea1421747985bd09ad40565da8536e857b5c2e9a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161568 --- vcl/source/window/dlgctrl.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index adf416b21769..90cdf353f8c0 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -941,7 +941,7 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput ) } } } - else if (aKeyCode.IsMod2()) // tdf#151385 + else { sal_Unicode c = rKEvt.GetCharCode(); if ( c ) @@ -952,8 +952,13 @@ bool Window::ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput ) GetFocusFlags nGetFocusFlags = GetFocusFlags::Mnemonic; if ( pSWindow == ::ImplFindAccelWindow( this, i, c, nFormStart, nFormEnd ) ) nGetFocusFlags |= GetFocusFlags::UniqueMnemonic; - pSWindow->ImplControlFocus( nGetFocusFlags ); - return true; + // tdf#157649 Allow omitting the Alt key when focus is in the dialog action area: + bool bIsButtonBox = dynamic_cast(pSWindow->GetParent()) != nullptr; + if ((bIsButtonBox && pSWindow->GetParent()->HasChildPathFocus(true)) || aKeyCode.IsMod2()) + { + pSWindow->ImplControlFocus( nGetFocusFlags ); + return true; + } } } } -- cgit