Focus behaviour on widget derived from a gtkentry
- From: Geert Janssens <info kobaltwit be>
- To: gtk-list gnome org
- Subject: Focus behaviour on widget derived from a gtkentry
- Date: Fri, 18 Nov 2011 18:11:39 +0100
Hi,
I've been banging my head against the wall for some time now on this problem:
I have a widget that is derived from a GtkEntry. The derived widget basically
does some additional validation checks during text entry, nothing more really.
If you like to see the complete code, you can browse it here:
http://svn.gnucash.org/trac/browser/gnucash/trunk/src/gnome-utils/gnc-amount-
edit.c
I am now having problems to set the focus on this widget programmatically. In
this particular use case, the widget is added to a GtkAssistant, and during
the prepare of the page showing this widget, I call a gtk_widget_grab_focus on
it. This does nothing.
If I do the same with a plain GtkEntry on the same assistant page in the same
prepare callback, this entry does get the focus. So I assume my custom widget
is not handling things properly.
Based on another thread I found on this list [1] I then tried adding connect a
callback to the focus-in-event signal in gnc_amount_edit_init like so:
g_signal_connect (G_OBJECT (gae), "focus-in-event",
G_CALLBACK (gnc_amount_edit_focus_in), NULL);
And the callback function simply call gtk_widget_grab_focus on the internal
GtkEntry widget:
static gboolean gnc_amount_edit_focus_in (GNCAmountEdit *gae,
GdkEvent *event,
gpointer data)
{
gtk_widget_grab_focus (GTK_WIDGET(&gae->entry));
return FALSE;
}
Stepping through the code in a debugger shows me that the callback is really
called, but it still doesn't set the focus.
I am sure I'm missing something, but I don't see it. Any hints ?
Geert
[1] http://www.mail-archive.com/gtk-list gnome org/msg02478.html
--
Kobalt W.I.T.
Web & Information Technology
Brusselsesteenweg 152
1850 Grimbergen
Tel : +32 479 339 655
Email: info kobaltwit be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]