Cursor right toggles expansion.

This commit is contained in:
Michael Drake 2013-07-09 13:47:06 +01:00
parent 11eed50de4
commit 0df23dda20
1 changed files with 15 additions and 5 deletions

View File

@ -1607,14 +1607,24 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
break; break;
case KEY_RIGHT: case KEY_RIGHT:
if (ns.curr != NULL && if (ns.curr != NULL) {
ns.curr->children != NULL) {
/* Step to first child */
if (!(ns.curr->flags & TREE_NODE_EXPANDED)) { if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
/* Need to expand node */ /* Toggle node to expanded */
treeview_node_expand(tree, ns.curr); 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) { } else if (ns.curr != NULL) {
/* Retain current node selection */ /* Retain current node selection */