Enable double click to launch from treeview.

This commit is contained in:
Michael Drake 2013-06-04 15:03:07 +01:00
parent 8692bb6876
commit 23a0520b40
2 changed files with 15 additions and 9 deletions

View File

@ -428,7 +428,6 @@ nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
{ {
struct treeview_node_msg msg; struct treeview_node_msg msg;
msg.msg = TREE_MSG_NODE_DELETE; msg.msg = TREE_MSG_NODE_DELETE;
msg.data.node_delete.node = n;
/* Destroy children first */ /* Destroy children first */
while (n->children != NULL) { while (n->children != NULL) {
@ -1116,11 +1115,14 @@ static bool treeview_node_mouse_action_cb(struct treeview_node *node, void *ctx)
/* Clear any existing selection */ /* Clear any existing selection */
redraw |= treeview_clear_selection(ma->tree, &r); redraw |= treeview_clear_selection(ma->tree, &r);
/* Toggle node expansion */
if (node->flags & TREE_NODE_EXPANDED) { if (node->flags & TREE_NODE_EXPANDED) {
err = treeview_node_contract(ma->tree, node); err = treeview_node_contract(ma->tree, node);
} else { } else {
err = treeview_node_expand(ma->tree, node); err = treeview_node_expand(ma->tree, node);
} }
/* Set up redraw */
redraw = true; redraw = true;
if (r.y0 > ma->current_y) if (r.y0 > ma->current_y)
r.y0 = ma->current_y; r.y0 = ma->current_y;
@ -1128,11 +1130,15 @@ static bool treeview_node_mouse_action_cb(struct treeview_node *node, void *ctx)
} else if ((node->type == TREE_NODE_ENTRY) && } else if ((node->type == TREE_NODE_ENTRY) &&
(ma->mouse & BROWSER_MOUSE_DOUBLE_CLICK) && click) { (ma->mouse & BROWSER_MOUSE_DOUBLE_CLICK) && click) {
struct treeview_node_msg msg;
msg.msg = TREE_MSG_NODE_LAUNCH;
msg.data.node_launch.mouse = ma->mouse;
/* Clear any existing selection */ /* Clear any existing selection */
redraw |= treeview_clear_selection(ma->tree, &r); redraw |= treeview_clear_selection(ma->tree, &r);
/* Tell client an entry was launched */ /* Tell client an entry was launched */
/* TODO */ tree->callbacks->entry(msg, n->client_data);
} else if (ma->mouse & BROWSER_MOUSE_PRESS_1 && } else if (ma->mouse & BROWSER_MOUSE_PRESS_1 &&
!(node->flags & TREE_NODE_SELECTED) && !(node->flags & TREE_NODE_SELECTED) &&

View File

@ -39,19 +39,19 @@ enum treeview_relationship {
enum treeview_msg { enum treeview_msg {
TREE_MSG_NODE_DELETE, TREE_MSG_NODE_DELETE,
TREE_MSG_FIELD_EDIT TREE_MSG_NODE_EDIT,
TREE_MSG_NODE_LAUNCH
}; };
struct treeview_node_msg { struct treeview_node_msg {
enum treeview_msg msg; /**< The message type */ enum treeview_msg msg; /**< The message type */
union { union {
struct { struct {
struct treeview_node *node; lwc_string *feild; /* The field being edited */
} node_delete; const char *text; /* The proposed new value */
} node_edit; /* Client may call treeview_update_node_* */
struct { struct {
struct treeview_node *node; browser_mouse_state mouse; /* Button / modifier used */
lwc_string *feild; } node_launch;
const char *text;
} field_edit;
} data; /**< The message data. */ } data; /**< The message data. */
}; };