include/vcl/ctrl.hxx | 1 + include/vcl/toolkit/calendar.hxx | 1 + vcl/source/control/calendar.cxx | 7 +++++++ vcl/source/control/ctrl.cxx | 7 ++++++- 4 files changed, 15 insertions(+), 1 deletion(-)
New commits: commit 87d756f3f5dfb55ee9edbcd5349f8107ee5945eb Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Feb 21 13:40:43 2023 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Feb 21 19:56:26 2023 +0000 tdf#142783 consider the Calendar Edit and DropDown as one compound control for the purpose of notification of loss of focus from the control Change-Id: I9191b413978549c6f8e1775dc96a696059150e4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147398 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx index 17c40ae66067..6300e27a747a 100644 --- a/include/vcl/ctrl.hxx +++ b/include/vcl/ctrl.hxx @@ -151,6 +151,7 @@ protected: virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual bool FocusWindowBelongsToControl(const vcl::Window* pFocusWin) const; public: SAL_DLLPRIVATE void ImplClearLayoutData() const; /** draws a frame around the give rectangle, onto the given device diff --git a/include/vcl/toolkit/calendar.hxx b/include/vcl/toolkit/calendar.hxx index a1a1cd90105a..9652bb44640f 100644 --- a/include/vcl/toolkit/calendar.hxx +++ b/include/vcl/toolkit/calendar.hxx @@ -93,6 +93,7 @@ public: private: virtual void StateChanged( StateChangedType nStateChange ) override; + virtual bool FocusWindowBelongsToControl(const vcl::Window* pFocusWin) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/calendar.cxx b/vcl/source/control/calendar.cxx index 421e159eee81..5f437ff0300e 100644 --- a/vcl/source/control/calendar.cxx +++ b/vcl/source/control/calendar.cxx @@ -1724,4 +1724,11 @@ void CalendarField::StateChanged( StateChangedType nStateChange ) } } +// tdf#142783 consider the Edit and its DropDown as one compound control for the purpose of +// notification of loss of focus from the control +bool CalendarField::FocusWindowBelongsToControl(const vcl::Window* pFocusWin) const +{ + return DateField::FocusWindowBelongsToControl(pFocusWin) || (mpFloatWin && mpFloatWin->ImplIsWindowOrChild(pFocusWin)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 09fb464e662e..6d6843b9c6e4 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -223,6 +223,11 @@ OUString Control::GetDisplayText() const return mxLayoutData ? mxLayoutData->m_aDisplayText : GetText(); } +bool Control::FocusWindowBelongsToControl(const vcl::Window* pFocusWin) const +{ + return ImplIsWindowOrChild(pFocusWin); +} + bool Control::EventNotify( NotifyEvent& rNEvt ) { if ( rNEvt.GetType() == NotifyEventType::GETFOCUS ) @@ -241,7 +246,7 @@ bool Control::EventNotify( NotifyEvent& rNEvt ) if ( rNEvt.GetType() == NotifyEventType::LOSEFOCUS ) { vcl::Window* pFocusWin = Application::GetFocusWindow(); - if ( !pFocusWin || !ImplIsWindowOrChild( pFocusWin ) ) + if ( !pFocusWin || !FocusWindowBelongsToControl(pFocusWin) ) { mbHasControlFocus = false; CompatStateChanged( StateChangedType::ControlFocus );