include/vcl/toolkit/edit.hxx | 2 ++ vcl/source/treelist/treelistbox.cxx | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
New commits: commit 8316409b68a97f0129b1fd67bcb8c61a7010ceec Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Sun Apr 20 23:03:52 2025 -0800 Commit: Jim Raykowski <rayk...@gmail.com> CommitDate: Mon Apr 21 17:43:01 2025 +0200 Resolves tdf#166186 Showing the context menu for in-place editing ends in-place editing (x11 only) Fixing this revealed that ESC ends in-place editing when the popup menu is active. Esc a second time ends the popup menu. This patch fixes this issue as well. Change-Id: Ia617d27fcdf7221263bc9b2ae96d8a8ebf934fc4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184400 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> diff --git a/include/vcl/toolkit/edit.hxx b/include/vcl/toolkit/edit.hxx index 7d4a866a5888..2451f89f2166 100644 --- a/include/vcl/toolkit/edit.hxx +++ b/include/vcl/toolkit/edit.hxx @@ -243,6 +243,8 @@ public: bool IsPassword() const { return mbPassword; } + bool IsActivePopup() const { return mbActivePopup; } + virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override; }; diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 1d327274e9dd..ba9d0d48ceb9 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -88,8 +88,10 @@ public: void StopEditing( bool bCancel ); void Hide(); const VclPtr<Edit> & GetEditWidget() const { return pEdit; }; -}; + void RemoveEscapeAccel() { Application::RemoveAccel(&aAccEscape); } + void InsertEscapeAccel() { Application::InsertAccel(&aAccEscape); } +}; // *************************************************************** namespace { @@ -103,6 +105,7 @@ public: virtual void dispose() override { pOwner = nullptr; Edit::dispose(); } virtual void KeyInput( const KeyEvent& rKEvt ) override; virtual void LoseFocus() override; + virtual void Command(const CommandEvent& rCEvt) override; }; } @@ -128,6 +131,16 @@ void MyEdit_Impl::LoseFocus() pOwner->LoseFocus(); } +void MyEdit_Impl::Command(const CommandEvent& rCEvt) +{ + if (rCEvt.GetCommand() == CommandEventId::ContextMenu) + { + pOwner->RemoveEscapeAccel(); // so escape ends the popup + Edit::Command(rCEvt); + pOwner->InsertEscapeAccel(); + } +} + SvInplaceEdit2::SvInplaceEdit2 ( vcl::Window* pParent, const Point& rPos, @@ -233,9 +246,8 @@ void SvInplaceEdit2::StopEditing( bool bCancel ) void SvInplaceEdit2::LoseFocus() { - if ( !bAlreadyInCallBack - && ((!Application::GetFocusWindow()) || !pEdit->IsChild( Application::GetFocusWindow()) ) - ) + if (!bAlreadyInCallBack && !pEdit->IsActivePopup() + && ((!Application::GetFocusWindow()) || !pEdit->IsChild(Application::GetFocusWindow()))) { bCanceled = false; aIdle.SetPriority(TaskPriority::REPAINT);