From 0df23dda20d830f55f3237a5bb2c61b9a409b691 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 9 Jul 2013 13:47:06 +0100 Subject: [PATCH] Cursor right toggles expansion. --- desktop/treeview.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/desktop/treeview.c b/desktop/treeview.c index 8dbfce5d1..88f9cc0d0 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -1607,14 +1607,24 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key, break; case KEY_RIGHT: - if (ns.curr != NULL && - ns.curr->children != NULL) { - /* Step to first child */ + if (ns.curr != NULL) { if (!(ns.curr->flags & TREE_NODE_EXPANDED)) { - /* Need to expand node */ + /* Toggle node to expanded */ treeview_node_expand(tree, ns.curr); + if (ns.curr->children != NULL) { + /* Step to first child */ + ns.curr->children->flags |= + TREE_NODE_SELECTED; + } else { + /* Retain current node selection */ + ns.curr->flags |= TREE_NODE_SELECTED; + } + } else { + /* Toggle node to contracted */ + treeview_node_contract(tree, ns.curr); + /* Retain current node selection */ + ns.curr->flags |= TREE_NODE_SELECTED; } - ns.curr->children->flags |= TREE_NODE_SELECTED; } else if (ns.curr != NULL) { /* Retain current node selection */