Re: Moving focus on Enter



(Sorry for reposting Lucas, i forgot to CC gtkmm-list)

http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Container.html#d24cb5e43953c698a5f6db24d186b263
and:
http://library.gnome.org/devel/gtk/2.10/GtkContainer.html#id3846070

So it seems there is no functionality to move it to the next widget;
you'd have to get the focus chain, get the pointer address of the
current focus widget, find it in the list, get the next widget, and
focus it using Gtk::Widget::grab_focus(). O(N) operation; too bad
GtkContainer doesn't keep track of the current focus widget.

(Previous post said O(1) operation, i meant O(N) operation of course)

Addition: You might want to use std::tr1::unordered_map<> or just a
Glib/C GHashTable to keep track of the focus widgets, would maybe
speed things up a little although traversing that list should be
exteremely fast anyway.

Milosz

On 9/12/07, Lucas Clemente Vella <lvella gmail com> wrote:
> How can I make the "Enter" key act like "Tab" inside a Dialog, moving the
> focus to the next widget?
>
> I have a Dialog with a sequence of Gtk::Entry, since most of the data entered
> is number, it is more convenient to press the KeyPad Enter instead of Tab.
>
> I had the idea of reimplementing on_key_press_event (GdkEventKey* event) of
> Dialog on a derived class, looking for the KP_Enter press event, but I could
> not find in the docs a way to make the Window focus to the next widget in the
> chain. How can this be done?
>
> --
> Lucas Clemente Vella
> lvella gmail com
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]