Re: [GTK3] GtkEntry, why "focus-in-event" does not work ?
- From: Gilles DOFFE <g doffe gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: [GTK3] GtkEntry, why "focus-in-event" does not work ?
- Date: Thu, 23 Feb 2012 15:08:52 +0100
Thanks Jacky !
It was big enough in gtk3 documentation but I missed it anyway... ^^'
http://developer.gnome.org/gtk3/3.2/GtkWidget.html#GtkWidget-focus-in-event
Solved.
2012/2/23 jjacky <i am jack mail gmail com>
On 02/23/2012 02:49 PM, Gilles DOFFE wrote:
Hello,
Below a simple application with a GtkButton and a GtkEntry.
Two callbacks associated to this widgets following this rules :
1) When I click on the GtkButton, it should display the GtkEntry pointer
value.
2) When I focus on the GtkEntry, it should display the GtkButton pointer
value.
Case 1) works perfectly but case 2) always give a different value for the
GtkButton pointer ?!
Did i miss something ?
That the signature for focus-in-event isn't the same[1], and that second
parameter you use in your printf is a pointer to the GdkEvent, not your
user_data (Also, this callback should return a gboolean value).
-j
[1]
http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-focus-in-event
Thanks,
Gilles
#include <gtk/gtk.h>
void
onEntryFocusIn(GtkWidget *entry, gpointer pData)
{
printf("pData = %p\n", (GtkWidget *)pData);
}
int main(int argc, char **argv)
{
GtkWidget *pWindow = NULL;
GtkWidget *pButton = NULL;
GtkWidget *pEntry = NULL;
GtkWidget *pHbx = NULL;
gtk_init(NULL, NULL);
pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
pButton = gtk_button_new();
pEntry = gtk_entry_new();
pHbx = gtk_hbox_new(FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pButton), FALSE, FALSE,
0);
gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pEntry), FALSE, FALSE,
0);
gtk_container_add(pWindow, pHbx);
g_signal_connect(G_OBJECT(pWindow), "destroy", (GCallback)
gtk_main_quit, NULL);
/* THIS WORKS : */
g_signal_connect(G_OBJECT(pButton), "clicked", (GCallback)
onEntryFocusIn, (gpointer)pEntry);
/* THIS DOES NOT WORK : */
g_signal_connect(G_OBJECT(pEntry), "focus-in-event", (GCallback)
onEntryFocusIn, (gpointer)pButton);
gtk_widget_show_all(pWindow);
printf("pEntry = %p\n", pEntry);
printf("pButton = %p\n", pButton);
gtk_main();
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]