summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-08 15:09:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-12-08 17:37:54 +0100
commitf68ee0c6fca2d0d1be0c9409ae89e46736190d9c (patch)
treef618bd9a4e4f919710960e758ecbb9054ffe5428
parentuse more OUStringLiteral in various (diff)
downloadcore-f68ee0c6fca2d0d1be0c9409ae89e46736190d9c.tar.gz
core-f68ee0c6fca2d0d1be0c9409ae89e46736190d9c.zip
only autopopup on mouse hover, not keyboard traversal
Change-Id: I4ec5c5c1d5a450a0d8531907da85216000cd6c4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126547 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/vcl/toolkit/treelistbox.hxx4
-rw-r--r--include/vcl/weld.hxx4
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx2
-rw-r--r--vcl/inc/salvtables.hxx4
-rw-r--r--vcl/source/app/salvtables.cxx2
-rw-r--r--vcl/source/treelist/svimpbox.cxx4
-rw-r--r--vcl/source/treelist/treelistbox.cxx1
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx16
8 files changed, 35 insertions, 2 deletions
diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx
index 999f3a52c6b6..69c07b422094 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -220,6 +220,7 @@ class VCL_DLLPUBLIC SvTreeListBox
bool mbQuickSearch; // Enables type-ahead search in the check list box.
bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does
bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does
+ bool mbSelectingByHover; // true during "Select" if it was due to hover
sal_Int8 mnClicksToToggle; // 0 == Click on a row not toggle its checkbox.
// 1 == Every click on row toggle its checkbox.
// 2 == First click select, second click toggle.
@@ -677,6 +678,9 @@ public:
void SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; }
bool GetHoverSelection() const { return mbHoverSelection; }
+ // only true during Select if the Select is due to a Hover
+ bool IsSelectDueToHover() const { return mbSelectingByHover; }
+
// Set when clicks toggle the checkbox of the row.
void SetClicksToToggle(sal_Int8 nCount) { mnClicksToToggle = nCount; }
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 561baaaa256b..d296f1bbdd4a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1277,6 +1277,10 @@ public:
// remove the selected nodes
virtual void remove_selection() = 0;
+ // only meaningful is call this from a "changed" callback, true if the change
+ // was due to mouse hovering over the entry
+ virtual bool changed_by_hover() const = 0;
+
virtual void vadjustment_set_value(int value) = 0;
virtual int vadjustment_get_value() const = 0;
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index a27fb53c09a4..7a959023d3e0 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -357,7 +357,7 @@ void ScCheckListMenuControl::selectMenuItem(size_t nPos, bool bSubMenuTimer)
if (bSubMenuTimer)
{
- if (maMenuItems[nPos].mxSubMenuWin)
+ if (maMenuItems[nPos].mxSubMenuWin && mxMenu->changed_by_hover())
{
ScListSubMenuControl* pSubMenu = maMenuItems[nPos].mxSubMenuWin.get();
queueLaunchSubMenu(nPos, pSubMenu);
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index b91ccb26cb7f..37c5930e4933 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1708,7 +1708,9 @@ public:
virtual void vadjustment_set_value(int nValue) override;
- void set_show_expanders(bool bShow) override;
+ virtual void set_show_expanders(bool bShow) override;
+
+ virtual bool changed_by_hover() const override;
virtual ~SalInstanceTreeView() override;
};
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 78148cd10ea8..f0a2f9f7a6f4 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4904,6 +4904,8 @@ void SalInstanceTreeView::set_show_expanders(bool bShow)
m_xTreeView->set_property("show-expanders", OUString::boolean(bShow));
}
+bool SalInstanceTreeView::changed_by_hover() const { return m_xTreeView->IsSelectDueToHover(); }
+
SalInstanceTreeView::~SalInstanceTreeView()
{
LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index af40a630e698..fd3f43263c45 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -2048,7 +2048,11 @@ void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
if (!pEntry)
m_pView->SelectAll(false);
else if (!m_pView->IsSelected(pEntry) && IsSelectable(pEntry))
+ {
+ m_pView->mbSelectingByHover = true;
m_pView->Select(pEntry);
+ m_pView->mbSelectingByHover = false;
+ }
}
}
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index f8cfaaf6a311..2c48095e0f6b 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -397,6 +397,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) :
mbQuickSearch(false),
mbActivateOnSingleClick(false),
mbHoverSelection(false),
+ mbSelectingByHover(false),
mnClicksToToggle(0), //at default clicking on a row won't toggle its default checkbox
eSelMode(SelectionMode::NONE),
nMinWidthInChars(0),
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 760c9a45652f..6f4c47815744 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -13263,6 +13263,7 @@ private:
std::vector<int> m_aSavedSortColumns;
bool m_bWorkAroundBadDragRegion;
bool m_bInDrag;
+ bool m_bChangedByMouse;
gint m_nTextCol;
gint m_nTextView;
gint m_nImageCol;
@@ -13297,6 +13298,14 @@ private:
//has been processed
if (m_pChangeEvent)
Application::RemoveUserEvent(m_pChangeEvent);
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
+ GdkEvent *pEvent = gtk_get_current_event();
+ m_bChangedByMouse = pEvent && categorizeEvent(pEvent) == VclInputFlags::MOUSE;
+#else
+ //TODO maybe iterate over gtk_widget_observe_controllers looking for a motion controller
+#endif
+
m_pChangeEvent = Application::PostUserEvent(LINK(this, GtkInstanceTreeView, async_signal_changed));
}
@@ -13959,6 +13968,7 @@ public:
, m_pTreeModel(gtk_tree_view_get_model(m_pTreeView))
, m_bWorkAroundBadDragRegion(false)
, m_bInDrag(false)
+ , m_bChangedByMouse(false)
, m_nTextCol(-1)
, m_nTextView(-1)
, m_nImageCol(-1)
@@ -15758,6 +15768,11 @@ public:
gtk_tree_view_set_show_expanders(m_pTreeView, bShow);
}
+ virtual bool changed_by_hover() const override
+ {
+ return m_bChangedByMouse;
+ }
+
virtual ~GtkInstanceTreeView() override
{
if (m_pChangeEvent)
@@ -15813,6 +15828,7 @@ IMPL_LINK_NOARG(GtkInstanceTreeView, async_signal_changed, void*, void)
{
m_pChangeEvent = nullptr;
signal_changed();
+ m_bChangedByMouse = false;
}
IMPL_LINK_NOARG(GtkInstanceTreeView, async_stop_cell_editing, void*, void)