tags:

views:

90

answers:

1

Hi, I want to do a g_signal_connect to capture a mouse click in a gtk_entry widget.

Something like this:

entry = gtk_entry_new ( );
gtk_box_pack_end ( GTK_BOX ( hBox ), entry, TRUE, TRUE, 1 );
gtk_widget_show ( entry );

// This is the one I'm not sure about
g_signal_connect ( GTK_OBJECT ( entry ), "????????????", 
GTK_SIGNAL_FUNC ( EntryClicked ), entry );

I just can't seem to find it in the gtk documentation.

I've tried using the "focus-in-event", but it is not working as I spect.

Thanks for the assistance.

A: 

Mouse clicks are reported using the button-press-event signal, that's what you should connect:

g_signal_connect(G_OBJECT(entry), "button-press-event", G_CALLBACK(evt_entry_button_press), NULL);

This of course assumes you've defined a compatible function to handle the function. The "evt_" prefix on the handler's name is a simple convention I use personally.

This event is defined by the base GtkWidget class, which might be why you had problems finding it in the documentation for the GtkEntry widget.

unwind