Re: [gtk-list] Re: Getting selection from a CList?
- From: Jeremy Wise <jwise pathwaynet com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Getting selection from a CList?
- Date: Thu, 3 Sep 1998 18:01:29 -0400 (EDT)
On Wed, 2 Sep 1998, Aaron Walker wrote:
> Olof Oberg wrote:
>
> > I talked to _Codex about it this week. I think he will fix it
> > soon. For single selections it should just be returning
> > gtkclist->selection as is and for multiple selections one has
> > to consider which format the 'selection list' should be in.
> >
> > What I dont understand what gtk_get_selection_info(....) does
> > though.
> >
> > Btw, how do you do it with catching signals?
>
> here's how I do it...
>
> gchar *titles[2] = {"Col 1", "Col 2"};
> GtkWidget *clist;
>
> clist = gtk_clist_new_with_titles(2, titles);
> gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(clist_cb),
> NULL);
> gtk_widget_show(clist);
>
> the callback...
>
> void clist_cb ( GtkWidget *clist, gint row, gint column,
> GdkEventButton *event, gpointer data)
> {
> gchar *text;
> gtk_clist_get_text(GTK_CLIST(clist), row, column, &text);
>
> /* ... */
> }
>
> Unfortunately, this only does single clicks :(
> does anyone know how to bind double click events to the clist?
Yes... You just need to check event->type, and to see which button, check
event->button. for example:
switch( event->button )
{
case 1: /* First button (1, 2, 3 are the 3 buttons) */
switch( event->type )
{
case GDK_BUTTON_PRESS:
stuff for one button press...
case GDK_2BUTTON_PRESS:
stuff for double click....
case GDK_3BUTTON_PRESS:
stuff for triple click....
}
case 2:
middle button stuff...
and so on... One caution: a double click will call this routine THREE
times....once for the first click GDK_BUTTON_PRESS, once for the 2nd
click, again GDK_BUTTON_PRESS, and once for the GDK_2BUTTON_PRESS. Plan
accordingly ;-)
Later,
Jeremy Wise
jwise@pathwaynet.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]