diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-11 19:36:40 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-11 22:20:02 +0100 |
commit | 812ee330e6977fcd7db614b5116581ed1e4c8013 (patch) | |
tree | 6ac844b497202c6cc6f1b57ffb6e314ef50892c7 | |
parent | d5f735ecec90e25d423f0f2bc1b5476e6d7c4196 (diff) | |
download | serenity-812ee330e6977fcd7db614b5116581ed1e4c8013.zip |
GTreeView: Make it possible to multi-select with the Ctrl modifier
-rw-r--r-- | Libraries/LibGUI/GTreeView.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Libraries/LibGUI/GTreeView.cpp b/Libraries/LibGUI/GTreeView.cpp index 29bdb05743..716eaccda8 100644 --- a/Libraries/LibGUI/GTreeView.cpp +++ b/Libraries/LibGUI/GTreeView.cpp @@ -66,15 +66,21 @@ void GTreeView::mousedown_event(GMouseEvent& event) auto adjusted_position = event.position().translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); bool is_toggle; auto index = index_at_content_position(adjusted_position, is_toggle); - if (!index.is_valid()) + if (!index.is_valid()) { + if (event.button() == GMouseButton::Left && !(event.modifiers() & Mod_Ctrl)) + selection().clear(); return; - - if (selection().first() != index) { - selection().set(index); } - if (is_toggle && model.row_count(index)) - toggle_index(index); + if (event.button() == GMouseButton::Left) { + if (event.modifiers() & Mod_Ctrl) { + selection().toggle(index); + } else { + selection().set(index); + } + if (is_toggle && model.row_count(index)) + toggle_index(index); + } } void GTreeView::doubleclick_event(GMouseEvent& event) |