Re: [gtk-list] How to handle double-click in CTree vs CList
- From: Allan Black <allan genia scotnet co uk>
- To: gtk-list redhat com
- Cc: nneul umr edu
- Subject: Re: [gtk-list] How to handle double-click in CTree vs CList
- Date: Fri, 14 May 1999 16:20:41 +0100 (BST)
> I recently changed GTKYahoo to use a CTree instead of CList for the user
> listing. The problem is that now I have lost the ability to easily handle
> double-clicks.
>
> Is there any quick and easy way to handle double-clicks in a ctree widget?
This is what I do ....
gtk_signal_connect(GTK_OBJECT(ctree), "button_press_event",
GTK_SIGNAL_FUNC(ctreebutton), data);
(as you would expect) when I create the ctree and ....
gtk_ctree_node_set_row_data(GTK_CTREE(ctree), node, MYDATA);
when I add nodes to the tree and then ....
static gint ctreebutton(GtkWidget *w, GdkEventButton *bu, gpointer data)
{
GtkCTreeNode *ctn;
MYDATATYPE *item;
gint row, column;
if(bu->button == 1) {
if(bu->type == GDK_2BUTTON_PRESS) {
if(!gtk_clist_get_selection_info(GTK_CLIST(w),
(gint)bu->x, (gint)bu->y,
&row, &column))
return FALSE;
fprintf(stderr, "double click at row %d\n", row);
ctn = gtk_ctree_node_nth(GTK_CTREE(w), row);
if(ctn == (GtkCTreeNode *)0) return FALSE;
item = gtk_ctree_node_get_row_data(GTK_CTREE(w), ctn);
if(item) MY_DOUBLE_CLICK_ACTION(item);
}
}
return TRUE;
}
The important points are:
gtk_clist_get_selection_info() tells you which row (and column, as
it happens) corresponds to the coordinates you provide, in
this case bu->x and bu->y - the coords of the double click.
gtk_ctree_node_nth() gives you the ctree node corresponding to the
clist row you supply.
gtk_ctree_node_get_row_data() gives you back the user data you
"attached" to the node when you inserted it into the ctree.
Allan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]