[Libreoffice-commits] core.git: include/svtools svtools/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 18 20:25:33 UTC 2021


 include/svtools/brwbox.hxx              |    1 +
 include/svtools/editbrowsebox.hxx       |   10 ++++++++++
 svtools/source/brwbox/brwbox2.cxx       |    4 ++++
 svtools/source/brwbox/ebbcontrols.cxx   |   20 ++++++++++++++++++++
 svtools/source/brwbox/editbrowsebox.cxx |   11 +++++------
 5 files changed, 40 insertions(+), 6 deletions(-)

New commits:
commit 422a8c3218b484817a8723b57fe9845d6abb83f4
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 18 17:22:31 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 18 21:24:43 2021 +0100

    update DataBrowser has-focus when child widget loses focus
    
    similar to tdf#135641 case, focus-out becomes an issue with
    the bibliography editor if focus-in is seen on clicking in a cell,
    then click in a GtkEntry and tab around in a circle. Without this
    lose-focus support focus will be grabbed back to the cell of the
    initial click on a circuit of the focus-cycle
    
    Change-Id: I36288ed21dc4357c077f8dee55b55abf2457c2a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111157
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx
index 8e7b3fc6f4dc..948650015e19 100644
--- a/include/svtools/brwbox.hxx
+++ b/include/svtools/brwbox.hxx
@@ -588,6 +588,7 @@ public:
     tools::Rectangle       GetControlArea() const;
     virtual bool    ProcessKey(const KeyEvent& rEvt);
     virtual void    ChildFocusIn();
+    virtual void    ChildFocusOut();
     void            Dispatch( sal_uInt16 nId );
     void            SetMode( BrowserMode nMode );
     BrowserMode     GetMode( ) const { return m_nCurrentMode; }
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 34696522bd78..6ff261e2e254 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -174,6 +174,7 @@ namespace svt
     protected:
         DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
         DECL_LINK(FocusInHdl, weld::Widget&, void);
+        DECL_LINK(FocusOutHdl, weld::Widget&, void);
     };
 
     class SVT_DLLPUBLIC EditControlBase : public ControlBase
@@ -191,6 +192,7 @@ namespace svt
         weld::Entry& get_widget() { return *m_pEntry; }
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) = 0;
 
     protected:
         void InitEditControlBase(weld::Entry* pEntry);
@@ -211,6 +213,11 @@ namespace svt
             m_xWidget->connect_changed(rLink);
         }
 
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override
+        {
+            m_xWidget->connect_focus_out(rLink);
+        }
+
     protected:
         std::unique_ptr<weld::Entry> m_xWidget;
     };
@@ -696,6 +703,7 @@ namespace svt
         virtual void dispose() override;
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
 
         weld::EntryFormatter& get_formatter();
 
@@ -762,6 +770,7 @@ namespace svt
         weld::PatternFormatter& get_formatter() { return *m_xEntryFormatter; }
 
         virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+        virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
 
         virtual void dispose() override;
     private:
@@ -995,6 +1004,7 @@ namespace svt
         virtual bool ProcessKey(const KeyEvent& rEvt) override;
 
         virtual void ChildFocusIn() override;
+        virtual void ChildFocusOut() override;
 
         css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCheckBoxCell(sal_Int32 _nRow, sal_uInt16 _nColumnPos,const TriState& eState);
         bool ControlHasFocus() const;
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index 3ad89e4a4bbc..e52421f9cdcd 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -1690,6 +1690,10 @@ void BrowseBox::ChildFocusIn()
 {
 }
 
+void BrowseBox::ChildFocusOut()
+{
+}
+
 void BrowseBox::Dispatch( sal_uInt16 nId )
 {
 
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index db614a86c31c..35fb994daaea 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -31,6 +31,7 @@ namespace svt
         m_xWidget->connect_changed(LINK(this, ComboBoxControl, SelectHdl));
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     void ComboBoxControl::dispose()
@@ -117,6 +118,7 @@ namespace svt
         m_xWidget->connect_changed(LINK(this, ListBoxControl, SelectHdl));
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     void ListBoxControl::dispose()
@@ -186,6 +188,7 @@ namespace svt
         InitControlBase(m_xBox.get());
         m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xBox->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xBox->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
         m_xBox->connect_toggled(LINK(this, CheckBoxControl, OnToggle));
     }
 
@@ -338,6 +341,7 @@ namespace svt
         m_pEntry->set_width_chars(1); // so a smaller than default width can be used
         m_pEntry->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_pEntry->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
     }
 
     bool ControlBase::ProcessKey(const KeyEvent& rKEvt)
@@ -355,6 +359,11 @@ namespace svt
         return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusIn();
     }
 
+    IMPL_LINK_NOARG(ControlBase, FocusOutHdl, weld::Widget&, void)
+    {
+        return static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusOut();
+    }
+
     void EditControlBase::dispose()
     {
         m_pEntry = nullptr;
@@ -392,6 +401,11 @@ namespace svt
         get_formatter().connect_changed(rLink);
     }
 
+    void FormattedControlBase::connect_focus_out(const Link<weld::Widget&, void>& rLink)
+    {
+        get_formatter().connect_focus_out(rLink);
+    }
+
     weld::EntryFormatter& FormattedControlBase::get_formatter()
     {
         return *m_xEntryFormatter;
@@ -530,6 +544,11 @@ namespace svt
         m_xEntryFormatter->connect_changed(rLink);
     }
 
+    void PatternControl::connect_focus_out(const Link<weld::Widget&, void>& rLink)
+    {
+        m_xEntryFormatter->connect_focus_out(rLink);
+    }
+
     void PatternControl::dispose()
     {
         m_xEntryFormatter.reset();
@@ -618,6 +637,7 @@ namespace svt
         InitControlBase(m_xWidget.get());
         m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
         m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
+        m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
         // so any the natural size doesn't have an effect
         m_xWidget->set_size_request(1, 1);
     }
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 71126b5a3f4b..236897d0d96e 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -160,7 +160,6 @@ namespace svt
         nEditCol = 0;
     }
 
-
     VclPtr<BrowserHeader> EditBrowseBox::CreateHeaderBar(BrowseBox* pParent)
     {
         pHeader = imp_CreateHeaderBar(pParent);
@@ -169,20 +168,17 @@ namespace svt
         return pHeader;
     }
 
-
     VclPtr<BrowserHeader> EditBrowseBox::imp_CreateHeaderBar(BrowseBox* pParent)
     {
         return VclPtr<EditBrowserHeader>::Create(pParent);
     }
 
-
     void EditBrowseBox::LoseFocus()
     {
         BrowseBox::LoseFocus();
         DetermineFocus();
     }
 
-
     void EditBrowseBox::GetFocus()
     {
         BrowseBox::GetFocus();
@@ -195,14 +191,12 @@ namespace svt
         DetermineFocus(getRealGetFocusFlags(this));
     }
 
-
     bool EditBrowseBox::SeekRow(sal_Int32 nRow)
     {
         nPaintRow = nRow;
         return true;
     }
 
-
     IMPL_LINK_NOARG(EditBrowseBox, StartEditHdl, void*, void)
     {
         nStartEvent = nullptr;
@@ -418,6 +412,11 @@ namespace svt
         DetermineFocus(getRealGetFocusFlags(this));
     }
 
+    void EditBrowseBox::ChildFocusOut()
+    {
+        DetermineFocus();
+    }
+
     void EditBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
     {
         // absorb double clicks


More information about the Libreoffice-commits mailing list