diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-22 20:48:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-23 10:00:48 +0200 |
commit | 5c961a0412467d444dc7bc92a4573f1769b7dc53 (patch) | |
tree | cd8b2b7c86eb79992fd740dfa249c9cc3f5574a4 | |
parent | 6baa7ab095b44c599a0db253e5484f673878cabc (diff) |
better focus in/out impl that doesn't depend on being a Control
Change-Id: I3ed1732895efa44b8ff60c410356ecb684f06ba3
Reviewed-on: https://gerrit.libreoffice.org/53297
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/app/salvtables.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 1379984faa54..ab1d797c8aba 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -183,8 +183,8 @@ class SalInstanceWidget : public virtual weld::Widget private: VclPtr<vcl::Window> m_xWidget; - DECL_LINK(FocusInHdl, Control&, void); - DECL_LINK(FocusOutHdl, Control&, void); + DECL_LINK(FocusInListener, VclWindowEvent&, void); + DECL_LINK(FocusOutListener, VclWindowEvent&, void); bool m_bTakeOwnership; @@ -340,14 +340,14 @@ public: virtual void connect_focus_in(const Link<Widget&, void>& rLink) override { assert(!m_aFocusInHdl.IsSet()); - dynamic_cast<Control&>(*m_xWidget).SetGetFocusHdl(LINK(this, SalInstanceWidget, FocusInHdl)); + m_xWidget->AddEventListener(LINK( this, SalInstanceWidget, FocusInListener)); m_aFocusInHdl = rLink; } virtual void connect_focus_out(const Link<Widget&, void>& rLink) override { assert(!m_aFocusOutHdl.IsSet()); - dynamic_cast<Control&>(*m_xWidget).SetLoseFocusHdl(LINK(this, SalInstanceWidget, FocusOutHdl)); + m_xWidget->AddEventListener(LINK( this, SalInstanceWidget, FocusOutListener)); m_aFocusOutHdl = rLink; } @@ -366,9 +366,9 @@ public: virtual ~SalInstanceWidget() override { if (m_aFocusInHdl.IsSet()) - dynamic_cast<Control&>(*m_xWidget).SetGetFocusHdl(Link<Control&,void>()); + m_xWidget->RemoveEventListener(LINK( this, SalInstanceWidget, FocusInListener)); if (m_aFocusOutHdl.IsSet()) - dynamic_cast<Control&>(*m_xWidget).SetLoseFocusHdl(Link<Control&,void>()); + m_xWidget->RemoveEventListener(LINK( this, SalInstanceWidget, FocusOutListener)); if (m_bTakeOwnership) m_xWidget.disposeAndClear(); } @@ -384,14 +384,16 @@ public: } }; -IMPL_LINK_NOARG(SalInstanceWidget, FocusInHdl, Control&, void) +IMPL_LINK(SalInstanceWidget, FocusInListener, VclWindowEvent&, rEvent, void) { - signal_focus_in(); + if (rEvent.GetId() == VclEventId::WindowGetFocus || rEvent.GetId() == VclEventId::WindowActivate) + signal_focus_in(); } -IMPL_LINK_NOARG(SalInstanceWidget, FocusOutHdl, Control&, void) +IMPL_LINK(SalInstanceWidget, FocusOutListener, VclWindowEvent&, rEvent, void) { - signal_focus_out(); + if (rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::WindowDeactivate) + signal_focus_out(); } class SalInstanceMenu : public weld::Menu |