[Libreoffice-commits] core.git: vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 18 14:08:03 UTC 2020


 vcl/source/app/salvtables.cxx |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 7f5a87c501ba1291a93bf330cc1a1de19ea1d89c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 18 10:00:51 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Nov 18 15:07:22 2020 +0100

    tdf#138271 send value-changed on FormattedSpinButton losing focus
    
    Change-Id: Iaa6882f41ee756b0645818694f6942d90243ba13
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106049
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index caf7a5f5fafd..e866997880b8 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5486,6 +5486,10 @@ class SalInstanceFormattedSpinButton : public SalInstanceEntry,
 private:
     VclPtr<FormattedField> m_xButton;
     weld::EntryFormatter* m_pFormatter;
+    Link<weld::Widget&, void> m_aLoseFocusHdl;
+
+    DECL_LINK(UpDownHdl, SpinField&, void);
+    DECL_LINK(LoseFocusHdl, Control&, void);
 
 public:
     SalInstanceFormattedSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder,
@@ -5494,6 +5498,9 @@ public:
         , m_xButton(pButton)
         , m_pFormatter(nullptr)
     {
+        m_xButton->SetUpHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
+        m_xButton->SetDownHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
+        m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceFormattedSpinButton, LoseFocusHdl));
     }
 
     virtual void set_text(const OUString& rText) override
@@ -5517,7 +5524,7 @@ public:
     {
         if (!m_pFormatter) // once a formatter is set, it takes over "focus-out"
         {
-            SalInstanceEntry::connect_focus_out(rLink);
+            m_aLoseFocusHdl = rLink;
             return;
         }
         m_pFormatter->connect_focus_out(rLink);
@@ -5548,8 +5555,23 @@ public:
     {
         return m_xButton->GetFormatter();
     }
+
+    virtual ~SalInstanceFormattedSpinButton() override
+    {
+        m_xButton->SetLoseFocusHdl(Link<Control&, void>());
+        m_xButton->SetDownHdl(Link<SpinField&, void>());
+        m_xButton->SetUpHdl(Link<SpinField&, void>());
+    }
 };
 
+IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, UpDownHdl, SpinField&, void) { signal_value_changed(); }
+
+IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, LoseFocusHdl, Control&, void)
+{
+    signal_value_changed();
+    m_aLoseFocusHdl.Call(*this);
+}
+
 }
 
 SalInstanceLabel::SalInstanceLabel(Control* pLabel, SalInstanceBuilder* pBuilder,


More information about the Libreoffice-commits mailing list