[GTK3] GtkEntry, why "focus-in-event" does not work ?
- From: Gilles DOFFE <g doffe gmail com>
- To: gtk-app-devel-list gnome org
- Subject: [GTK3] GtkEntry, why "focus-in-event" does not work ?
- Date: Thu, 23 Feb 2012 14:49:49 +0100
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 ?
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();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]