mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibGUI: Hold down Alt when clicking TreeView to expand full subtree
On other operating systems, if you hold down Alt when you click to expand part of a tree, it expands all of the children of the node you clicked. This commit makes our TreeView act the same way :)
This commit is contained in:
parent
7809cc6557
commit
22d54cd446
2 changed files with 28 additions and 0 deletions
|
@ -430,6 +430,33 @@ void TreeView::did_update_selection()
|
||||||
activate(index);
|
activate(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TreeView::mousedown_event(MouseEvent& event)
|
||||||
|
{
|
||||||
|
if (!model())
|
||||||
|
return AbstractView::mousedown_event(event);
|
||||||
|
|
||||||
|
if (event.button() != MouseButton::Primary)
|
||||||
|
return AbstractView::mousedown_event(event);
|
||||||
|
|
||||||
|
bool is_toggle;
|
||||||
|
auto index = index_at_event_position(event.position(), is_toggle);
|
||||||
|
|
||||||
|
if (index.is_valid() && is_toggle && model()->row_count(index)) {
|
||||||
|
if (event.alt()) {
|
||||||
|
if (is_toggled(index)) {
|
||||||
|
collapse_tree(index);
|
||||||
|
} else {
|
||||||
|
expand_tree(index);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toggle_index(index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractView::mousedown_event(event);
|
||||||
|
}
|
||||||
|
|
||||||
void TreeView::keydown_event(KeyEvent& event)
|
void TreeView::keydown_event(KeyEvent& event)
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
TreeView();
|
TreeView();
|
||||||
|
|
||||||
|
virtual void mousedown_event(MouseEvent&) override;
|
||||||
virtual void paint_event(PaintEvent&) override;
|
virtual void paint_event(PaintEvent&) override;
|
||||||
virtual void doubleclick_event(MouseEvent&) override;
|
virtual void doubleclick_event(MouseEvent&) override;
|
||||||
virtual void keydown_event(KeyEvent&) override;
|
virtual void keydown_event(KeyEvent&) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue