summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-04 20:23:07 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-02-05 11:57:57 +0100
commit824a84a894755f2ce41f4612f27d2e1110676c6d (patch)
treeef34634ebdd50da780c22ff5d280a0a758edd740
parent349593166af244566fe0a8d2c11f3bcd73048c1d (diff)
Related: tdf#146836 daisy chain together some more event handlers
so old ones are not clobbered but are called from the new ones Change-Id: I4cdd25fc1f3b13b10711d5c2f30c46645ae6c968 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129503 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svtools/editbrowsebox.hxx19
-rw-r--r--svtools/source/brwbox/ebbcontrols.cxx33
2 files changed, 45 insertions, 7 deletions
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 9b7ac148150a..aa6b72441373 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -237,7 +237,9 @@ namespace svt
weld::Entry& get_widget() { return *m_pEntry; }
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) = 0;
+ virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) = 0;
virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) = 0;
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) = 0;
protected:
void InitEditControlBase(weld::Entry* pEntry);
@@ -258,11 +260,21 @@ namespace svt
m_xWidget->connect_changed(rLink);
}
+ virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override
+ {
+ m_xWidget->connect_focus_in(rLink);
+ }
+
virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override
{
m_xWidget->connect_focus_out(rLink);
}
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override
+ {
+ m_xWidget->connect_key_press(rLink);
+ }
+
protected:
std::unique_ptr<weld::Entry> m_xWidget;
};
@@ -758,7 +770,9 @@ namespace svt
virtual void dispose() override;
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+ virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override;
virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override;
weld::EntryFormatter& get_formatter();
@@ -817,7 +831,7 @@ namespace svt
DECL_DLLPRIVATE_LINK(ImplClickHdl, weld::Button&, void);
};
- class SVT_DLLPUBLIC PatternControl final : public EditControl
+ class SVT_DLLPUBLIC PatternControl final : public EditControlBase
{
public:
PatternControl(BrowserDataWin* pParent);
@@ -825,10 +839,13 @@ namespace svt
weld::PatternFormatter& get_formatter() { return *m_xEntryFormatter; }
virtual void connect_changed(const Link<weld::Entry&, void>& rLink) override;
+ virtual void connect_focus_in(const Link<weld::Widget&, void>& rLink) override;
virtual void connect_focus_out(const Link<weld::Widget&, void>& rLink) override;
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override;
virtual void dispose() override;
private:
+ std::unique_ptr<weld::Entry> m_xWidget;
std::unique_ptr<weld::PatternFormatter> m_xEntryFormatter;
};
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 9980d1ae469b..b6a27a2567f4 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -362,8 +362,8 @@ namespace svt
m_pEntry = pEntry;
m_pEntry->show();
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_key_press(LINK(this, ControlBase, KeyInputHdl));
+ connect_focus_in(LINK(this, ControlBase, FocusInHdl));
connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
m_pEntry->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
m_pEntry->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
@@ -447,11 +447,21 @@ namespace svt
get_formatter().connect_changed(rLink);
}
+ void FormattedControlBase::connect_focus_in(const Link<weld::Widget&, void>& rLink)
+ {
+ get_widget().connect_focus_in(rLink);
+ }
+
void FormattedControlBase::connect_focus_out(const Link<weld::Widget&, void>& rLink)
{
get_formatter().connect_focus_out(rLink);
}
+ void FormattedControlBase::connect_key_press(const Link<const KeyEvent&, bool>& rLink)
+ {
+ get_widget().connect_key_press(rLink);
+ }
+
weld::EntryFormatter& FormattedControlBase::get_formatter()
{
return *m_xEntryFormatter;
@@ -578,11 +588,11 @@ namespace svt
}
PatternControl::PatternControl(BrowserDataWin* pParent)
- : EditControl(pParent)
+ : EditControlBase(pParent)
+ , m_xWidget(m_xBuilder->weld_entry("entry"))
{
- m_xWidget->connect_key_press(Link<const KeyEvent&, bool>()); // 1) acknowledge we first remove the old one
m_xEntryFormatter.reset(new weld::PatternFormatter(*m_xWidget));
- m_xEntryFormatter->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); // 2) and here we reattach via the formatter
+ InitEditControlBase(m_xWidget.get());
}
void PatternControl::connect_changed(const Link<weld::Entry&, void>& rLink)
@@ -590,15 +600,26 @@ namespace svt
m_xEntryFormatter->connect_changed(rLink);
}
+ void PatternControl::connect_focus_in(const Link<weld::Widget&, void>& rLink)
+ {
+ m_xEntryFormatter->connect_focus_in(rLink);
+ }
+
void PatternControl::connect_focus_out(const Link<weld::Widget&, void>& rLink)
{
m_xEntryFormatter->connect_focus_out(rLink);
}
+ void PatternControl::connect_key_press(const Link<const KeyEvent&, bool>& rLink)
+ {
+ m_xEntryFormatter->connect_key_press(rLink);
+ }
+
void PatternControl::dispose()
{
m_xEntryFormatter.reset();
- EditControl::dispose();
+ m_xWidget.reset();
+ EditControlBase::dispose();
}
EditCellController::EditCellController(EditControlBase* pEdit)