Keyboard focus navigation question




Hi all,
If I have a simple application with just two buttons in it (such as the
'dialog' example from ch6 of Eric Harlows book,
http://www.bcpl.lib.md.us/~eharlow/book/), why is it that I have to hit
the Tab key (or the arrow key) *3* times to cycle through the 2 widgets?

The first press highlights the first widget, and the second press hilights
the second widget.  However, I would have expected a third press to
hilight the first widget again.  Instead though, neither button is
hilighted, and the keyboard focus seems to be nowhere.  Hitting the Tab
key again then sets the focus back to the first widget.

I did some digging into the code, and was able to make a change that gave
the desired results.  However, I'm unsure as to why the behaviour works as
it does, whether it is by design or a bug.
In gtkwindow.c, in gtk_window_key_press_event(), at line 1242, there is an
'if' that sees if the window has a focus_child or not.  If it doesn't, it
calls
        gtk_window_set_focus (GTK_WINDOW (widget), NULL);
Without really knowing the ramifications of my change, I changed this line
to be
	gtk_container_focus (GTK_CONTAINER(widget), GTK_DIR_TAB_FORWARD);
basically so that if the end of the list of focus children is reached, the
focus is automatically reset to the first one.  This resulted in the
behaviour that I expected to see, with no other obvious problems.

So, is this a bug or a feature?
Thanks for any info!
Ian
gtk+-1.2.6-1 (RPM), RedHat 6.0



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