diff options
author | Attila Szűcs <szucs.attila3@nisz.hu> | 2021-01-07 19:07:23 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-01-20 17:23:24 +0100 |
commit | 3d2a431da1126f4924f6cd7e5abac6488cd480e7 (patch) | |
tree | 1f1a7314b376aa331354f37c091f97e669be18d1 /vcl/source | |
parent | bd015917e8967b4e3c5325f01484fb53e00f9340 (diff) |
tdf#139115 vcl tree list: add new toggle behaviors
at clicking on list items with checkboxes to clean-up
generic VCL plugin commit 2471d6f44c7e8ecbe86a90eeb593b899a08a7408
(tdf#116675 vcl tree list: toggle by label click (e.g. in AutoFilter)).
This limits the new toggle-always to ScCheckListMenuControl
(e.g. AutoFilter).
set_clicks_to_toggle() options to set the effect of the
click on a treeview list item:
0 == clicking never toggles the checkbox (default setting)
1 == clicking always toggles the checkbox
2 == clicking only toggles the checkbox of a selected list item,
i.e. the first click selects a not selected list item, and
only the second click toggles its checkbox.
It would be better if we could set this information in the
.ui files, but I did not find a good way for that.
A good place in the code to call this function can be
found by searching for the .ui filename.
Co-authored-by: Tibor Nagy (NISZ)
Change-Id: I5c72d710508fc397f2b6f959d7680b23f8dc6f67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108947
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 5 | ||||
-rw-r--r-- | vcl/source/treelist/treelistbox.cxx | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 06d8c8f89533..6183b1a3ac24 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -4061,6 +4061,11 @@ void SalInstanceTreeView::set_toggle(const weld::TreeIter& rIter, TriState eStat set_toggle(rVclIter.iter, eState, col); } +void SalInstanceTreeView::set_clicks_to_toggle(int nToggleBehavior) +{ + m_xTreeView->SetClicksToToggle(nToggleBehavior); +} + void SalInstanceTreeView::set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) { weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter); diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 818c6481c0e5..5211bb56ecc1 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -399,6 +399,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) : mbQuickSearch(false), mbActivateOnSingleClick(false), mbHoverSelection(false), + mnClicksToToggle(0), //at default clicking on a row won't toggle its default checkbox eSelMode(SelectionMode::NONE), nMinWidthInChars(0), mnDragAction(DND_ACTION_COPYMOVE | DND_ACTION_LINK), @@ -2283,17 +2284,18 @@ void SvTreeListBox::Paint(vcl::RenderContext& rRenderContext, const tools::Recta void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt ) { + pImpl->m_pCursorOld = pImpl->m_pCursor; pImpl->MouseButtonDown( rMEvt ); } void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt ) { // tdf#116675 clicking on an entry should toggle its checkbox - if (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN)) + if (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0) { const Point aPnt = rMEvt.GetPosPixel(); SvTreeListEntry* pEntry = GetEntry(aPnt); - if (pEntry && pEntry->m_Items.size() > 0) + if (pEntry && pEntry->m_Items.size() > 0 && (mnClicksToToggle == 1 || pEntry == pImpl->m_pCursorOld)) { SvLBoxItem* pItem = GetItem(pEntry, aPnt.X()); // if the checkbox button was clicked, that will be toggled later, do not toggle here |