Re: GtkEntry update problems. Or: How do I force a widget to loose focus?
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: gtk-list gnome org
- Subject: Re: GtkEntry update problems. Or: How do I force a widget to loose focus?
- Date: Fri, 1 Jun 2007 13:51:34 +0200
On Fri, Jun 01, 2007 at 01:42:14PM +0200, Toralf Lund wrote:
> In one of our applications, we have lots of GtkEntry widgets that
> "mirror" values also stored in variables. For reasons I won't go into
> here, we don't want to change the variables in question each and every
> time a character is typed, so we are doing updates on the "activate" and
> "focus-out", which means that values are synchronised if the user moves
> the cursor e.g. to another GtkEntry field, and an update may also be
> forced by pressing Enter. That's very nearly what we want, but not
> quite. The problem is that the "focus-out" event only occurs if the user
> selects another that will accept focus. This is not the case for e.g.
> menu items or toolbar items, so no variables are updated when those are
> selected - and we want them to be.
>
> So, is there any way at all I can make sure my variable is updated in
> all cases where the user stops entering text and selects anther GUI
> item? Essentially, the problem would be solved if I could force the
> focus to be taken away from the GtkEntry widget, but how? I might use
> the "grab_focus" call, of course, but I would have to add this to
> signals on all other widgets, then, and even that may not help, since I
> don't necessarily have a widget that can accept focus. And I don't "see"
> the GtkEntry in question from inside signal handers for buttons, menu
> items etc, of course...
You do. When the action that requires to commit the update
first occurs, use gtk_window_set_focus() (you should be able
to "see" the window) to get the focused widget, check
whether it needs "activate" to be emitted on it (this can be
done for instance by marking it with g_object_set_data() and
then looking for the data) and call gtk_widget_activate() it
if does.
Yeti
--
http://gwyddion.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]