Re: [gtk-list] Question about GtkTree
- From: David Helder <dhelder umich edu>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Question about GtkTree
- Date: Tue, 26 Jan 1999 18:03:45 -0500 (EST)
I think you're on the right track - use the button_press_event.
Here's some sample code:
/* Connect button_press_event to tree and have it call tree_button_press
*/
gtk_signal_connect (GTK_OBJECT(tree), "button_press_event",
GTK_SIGNAL_FUNC(tree_button_press), NULL);
static gint
tree_button_press (GtkWidget *widget, GdkEventButton *event, void *data)
{
if (debug_level >= 3)
g_print ("tree_button_press\n");
/* if event->type == GDK_2BUTTON_PRESS, it's a double click */
/* here's some more sample code related to CTree's, which you
might want to switch to. */
if (event->button == 3)
{
/* Handle someone clicking the 3rd mouse button */
/* Get the selection information */
gtk_clist_get_selection_info (GTK_CLIST(tree), event->x, event->y,
&row, &column);
/* Select the clicked row */
if (row > -1)
gtk_clist_select_row (GTK_CLIST(tree), row, 0);
/* Down here I display a popup menu */
[...]
return TRUE;
}
return FALSE;
}
On Tue, 26 Jan 1999, Achint Sandhu wrote:
> Hi,
>
> Another newbie question. I am trying to run a callback if someone
> double clicks an item in a GtkTree. My original declaration for the
> callback was:
> void selectionChangedInTree(GtkWidget *theTree, gpointer object);
> I changed this to
> void selectionChangedInTree(GtkWidget *theTree, GdkEvent *event,
> gpointer object);
> and tried to look at the <event> to figure out whether the selection
> was a single click or a double click. I was using the following code to
> connect the signal:
> gtk_signal_connect(GTK_OBJECT(aTree), "selection_changed",
> GTK_SIGNAL_FUNC(selectionChangedInTree),
> (gpointer) this);
> This approach did not work, so I started looking at the different
> events I could use. I looked into the "button_press_event", but did not
> get very far with that.
>
> Any help/sample code would be greatly appreciated ...
>
> Cheers,
> Achint
>
> --
> Achint Sandhu
> Nortel Networks
>
> It must be remembered that there is nothing more difficult to plan, more
> doubtful of success, nor more dangerous to manage, than the creation of
> a
> new system. For the initiator has the enmity of all who would profit by
> the preservation of the old institutions and merely lukewarm defenders
> in
> those who would gain by the new ones.
> -- Machiavelli
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
>
__ _ __
___/ /__ __ __(_)__/ / David Helder - University of Michigan
/ _ / _ `/ |/ / / _ / dhelder@umich.edu
\_,_/\_,_/|___/_/\_,_/ http://www.eecs.umich.edu/~dhelder
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]