framework/source/uielement/menubarmanager.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 893f055c75393e9f0a08823e25ca7ee6703e7ffa Author: Justin Luth <jl...@mail.com> AuthorDate: Wed Jun 12 14:52:43 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Aug 14 13:34:44 2024 +0200 tdf#146769 menuBarManager: dispatch with KeyModifier Shift/Ctrl/Alt If any of the modifier keys are held down while a menu item is selected, dispatch the modifier keys along with the command. There is not anything using this yet, but (in an abandoned patch) I wanted to let the "Quit" command know if KEY_SHIFT is pressed, so I can imagine this ability could be very handy elsewhere. The infrastructure is all there behind the scenes, just this piece needed to be plugged in. So instead of abandoning it completely, let me put this piece in place so it is ready for the next guy who could use it. Change-Id: Iff45928872f8958bdb694771cae8dfb347c646ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171843 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 946aa636e8f3..f86a17afd77f 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -48,12 +48,14 @@ #include <uno/current_context.hxx> #include <unotools/cmdoptions.hxx> #include <toolkit/awt/vclxmenu.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <utility> #include <vcl/svapp.hxx> #include <vcl/sysdata.hxx> #include <vcl/menu.hxx> #include <vcl/settings.hxx> #include <vcl/commandinfoprovider.hxx> +#include <vcl/window.hxx> #include <sal/log.hxx> #include <svtools/acceleratorexecute.hxx> #include <svtools/miscopt.hxx> @@ -796,7 +798,7 @@ IMPL_LINK_NOARG( MenuBarManager, AsyncSettingsHdl, Timer*, void) IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool ) { URL aTargetURL; - Sequence<PropertyValue> aArgs; + std::vector<beans::PropertyValue> aArgs; Reference< XDispatch > xDispatch; { @@ -816,9 +818,18 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool ) if ( pMenu->GetUserValue( nCurItemId ) ) { // addon menu item selected - aArgs = { comphelper::makePropertyValue(u"Referer"_ustr, u"private:user"_ustr) }; + aArgs.push_back( + comphelper::makePropertyValue(u"Referer"_ustr, u"private:user"_ustr)); } + // pass along if SHIFT/CTRL/ALT/CMD keys are pressed down + const VclPtr<vcl::Window> pWindow + = VCLUnoHelper::GetWindow(m_xFrame->getContainerWindow()); + const sal_Int16 nKeys + = pWindow ? pWindow->GetPointerState().mnState & KEY_MODIFIERS_MASK : 0; + if (nKeys) + aArgs.push_back(comphelper::makePropertyValue(u"KeyModifier"_ustr, nKeys)); + xDispatch = pMenuItemHandler->xMenuItemDispatch; } } @@ -829,7 +840,7 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu, bool ) if (xDispatch.is()) { SolarMutexReleaser aReleaser; - xDispatch->dispatch( aTargetURL, aArgs ); + xDispatch->dispatch(aTargetURL, comphelper::containerToSequence(aArgs)); } if ( !m_bHasMenuBar )