include/sfx2/infobar.hxx | 1 + sfx2/source/dialog/infobar.cxx | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)
New commits: commit 45b2c22d18c67c6da49789cbe5cd157874c7ba71 Author: Okhuomon Ajayi <[email protected]> AuthorDate: Wed Oct 29 14:24:30 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Nov 12 10:43:45 2025 +0100 tdf#129028: Prevent Infobar keys from reaching the document When the Infobar had focus, Delete, Backspace, arrows, and other keys still reached the document, causing unwanted edits/navigation. Override SfxInfoBarWindow::EventNotify so that only Tab/Space/Enter continue up to the parent, while every other key is consumed inside the Infobar. Change-Id: Ieb8d43849d3542ed115d6837d7d222dbf4e5ef31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193152 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx index 675a8fb0182d..eb09491c3081 100644 --- a/include/sfx2/infobar.hxx +++ b/include/sfx2/infobar.hxx @@ -83,6 +83,7 @@ public: bool bShowCloseButton); Size DoLayout(); virtual void Layout() override; + virtual bool EventNotify(NotifyEvent& rEvent) override; virtual ~SfxInfoBarWindow() override; virtual void dispose() override; diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 1ff57326ce6c..56964ec8ae17 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -23,6 +23,7 @@ #include <sfx2/sfxsids.hrc> #include <sfx2/viewfrm.hxx> #include <utility> +#include <vcl/event.hxx> #include <vcl/image.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> @@ -293,6 +294,28 @@ void SfxInfoBarWindow::Layout() m_bLayingOut = false; } +bool SfxInfoBarWindow::EventNotify(NotifyEvent& rEvent) +{ + const NotifyEventType nType = rEvent.GetType(); + if (NotifyEventType::KEYINPUT == nType) + { + const vcl::KeyCode& rKeyCode = rEvent.GetKeyEvent()->GetKeyCode(); + switch (rKeyCode.GetCode()) + { + case KEY_TAB: + case KEY_SPACE: + case KEY_RETURN: + // Allow Tab, Space, and Enter to pass through to parent for proper focus handling + break; + default: + // Consume all other keys to prevent document window interaction + return true; + } + } + + return InterimItemWindow::EventNotify(rEvent); +} + weld::Button& SfxInfoBarWindow::addButton(const OUString* pCommand) { m_aActionBtns.emplace_back(std::make_unique<ExtraButton>(m_xButtonBox.get(), pCommand));
