Re: [gtk-list] Another list question



On Thu, 15 May 1997, Marc van Kempen wrote:

> Is it possible have an action performend when doubleclicking on 
> a listitem?
> 
> Judging from the list of signals possible for a list widget
> it does not seem possible:
> 	selection_changed
> 	select_child
> 	unselect_child
> 

define a signal handler:

gint
signal_handler_event	(GtkWidget	*widget,
			 GdkEventButton	*event,
			 gpointer	func_data)
{
	if (GTK_IS_LIST_ITEM(widget) &&
	    ( event->type==GDK_2BUTTON_PRESS ||
	      event->type==GDK_3BUTTON_PRESS) ) {

		printf("list item: i feel %s clicked on button %d\n",
			event->type==GDK_2BUTTON_PRESS ? "double" : "triple",
			event->button);
	}
	
	return FALSE;
}

and connect the handler to your object:

{
	... list, listitem etc. init stuff
	
	gtk_signal_connect	(GTK_OBJECT(list_item),
				 "button_press_event",
				 GTK_SIGNAL_FUNC(signal_handler_event),
				 NULL);
	/* and/or */
	gtk_signal_connect	(GTK_OBJECT(list_item),
				 "button_release_event",
				 GTK_SIGNAL_FUNC(signal_handler_event),
				 NULL);
	
	... something else...
}


---
ciaoTJ

Tim.Janik@Hamburg.Netsurf.DE	[signature: <CENS||ED>]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]