Notebooks and TAB_TRAVERSAL

Attached is a sample app that is confusing me. It is a notebook whose
pages contain 2 panels - a parent and a child. Tab from the notebook
tabs causes focus to appear on the child. Tab or right arrow does
nothing while Tab backwards puts focus back on the notebook.

Why doesn't the focus appear initially on the parent panel which was
created first?

Why doesn't the focus travel to the parent panel when tab is hit on
the child panel?

The problem in my own app involves my inability to tab into a notebook
page that looks like Panel-Panel-Panel-StaticText. None of the Panels
receive focus from the tab and I assume its trying to go to the ST
which won't accept focus.

Mark

bug_nb_focus.py (2.19 KB)

Attached is a sample app that is confusing me. It is a notebook whose
pages contain 2 panels - a parent and a child. Tab from the notebook
tabs causes focus to appear on the child. Tab or right arrow does
nothing while Tab backwards puts focus back on the notebook.

Why doesn't the focus appear initially on the parent panel which was
created first?

Probably because panels cannot accept focus if they have children that
can accept focus.

Why doesn't the focus travel to the parent panel when tab is hit on
the child panel?

See above

The problem in my own app involves my inability to tab into a notebook
page that looks like Panel-Panel-Panel-StaticText. None of the Panels
receive focus from the tab and I assume its trying to go to the ST
which won't accept focus.

Mark

I can't be sure, but you may be able to force it to accept focus using
some style flag. I'm sure Robin or Chris B. will know though.

···

On Apr 5, 3:26 pm, Mark Reed <markree...@gmail.com> wrote:

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Probably because panels cannot accept focus if they have children that
can accept focus.

Yeah, but shouldn't TAB then still move the focus say back onto the
notebook instead of doing nothing? I thought TAB cycled through
everything. I am aware of Ctrl-Tab for tabbing out to the notebook,
but if tab goes into the controls on the page and Shift-Tab allows you
to tab back onto the notebook this must be a bug in that TAB itself
doesn't tab us back onto the notebook? This behavior would be
confusing to the user no?. This is one of my problems as I had
wx.WANTS_CHARS and was handling TAB myself by sending self.Navigate()
and I got confused when self.Navigate did nothing. Handling Shift-Tab
and Ctrl-Tab allowed me to tab away in this case. But TAB should cycle
in the simple app I posted earlier.

After creating all the children of the parent panel, the AcceptsFocus
functions are returning true which is confusing me. How do you
determine if a window is in the tab order?

I'm still stuck in my app with a notebook page that is Panel-Panel-
Panel-StaticText and it doesn't receive focus with a tab from the
notebook - however a simple app setup the same way does. I'm using the
Widget Inspection Tool and here is the event output for my notebook
and two top level panels on separate notebook pages. I cleared the
events and then while showing the QuizPanels page and focus on the
notebook, I hit a single TAB and I end up with focus on a control in
the MediaPanel which is 2 tabs away on the notebook. I assume that
this control is next in the tab order somehow??? Should TAB from a
notebook allow focus to pass to a hidden page?


The Widget Inspection Tool, and the tip to use a timer and check
wx.Window.FindFocus() has helped, but I am still baffled as to what is
going on here with TAB order. QuizPanel in this case does not bind any
of those events so my code should not be affecting the problem..

In the notebook demos if you select a page TAB will tab through the
controls on the page and back to the notebook - either tab direction
is fine. I assume this is the expected behavior?

Mark

Just a technicality, but they do accept focus, they just immediately pass it on to their child if they have any.

···

On 4/5/10 2:18 PM, Mike Driscoll wrote:

On Apr 5, 3:26 pm, Mark Reed<markree...@gmail.com> wrote:

Attached is a sample app that is confusing me. It is a notebook whose
pages contain 2 panels - a parent and a child. Tab from the notebook
tabs causes focus to appear on the child. Tab or right arrow does
nothing while Tab backwards puts focus back on the notebook.

Why doesn't the focus appear initially on the parent panel which was
created first?

Probably because panels cannot accept focus if they have children that
can accept focus.

--
Robin Dunn
Software Craftsman

Probably because panels cannot accept focus if they have children that
can accept focus.

Yeah, but shouldn't TAB then still move the focus say back onto the
notebook instead of doing nothing? I thought TAB cycled through
everything. I am aware of Ctrl-Tab for tabbing out to the notebook,
but if tab goes into the controls on the page and Shift-Tab allows you
to tab back onto the notebook this must be a bug in that TAB itself
doesn't tab us back onto the notebook?

I've wondered about that myself. I've also noticed that sometimes when the notebook page has widgets that the tab traversal stops at the last widget. I would at least expect it to cycle around to the beginning of the page if it can't go back to the notebook for some reason.

I don't know what the right answer is here, as there may be some intentional reason that it is working the way that it is, or it may be that that part of the tab traversal is being handled by the platform and so it's working the way MS says it should. But go ahead and raise the issue in a bug ticket so the appropriate wx developers will see it and can let us know.

This behavior would be
confusing to the user no?. This is one of my problems as I had
wx.WANTS_CHARS and was handling TAB myself by sending self.Navigate()
and I got confused when self.Navigate did nothing. Handling Shift-Tab
and Ctrl-Tab allowed me to tab away in this case. But TAB should cycle
in the simple app I posted earlier.

After creating all the children of the parent panel, the AcceptsFocus
functions are returning true which is confusing me. How do you
determine if a window is in the tab order?

The default implementation of AcceptsFocus (which is the one that wx.Panel inherits) is defined like this:

     virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }

So it will always return true if it's shown and enabled. However that doesn't necessarily mean that it is a tab-stop, just that the focus can be given to it. As I mentioned in the other mail, the panel will essentially just pass it on to the first child that will take it.

···

On 4/5/10 6:07 PM, Mark wrote:

--
Robin Dunn
Software Craftsman

Well, that's what I meant. :wink:

- Mike

···

On Apr 5, 11:17 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 4/5/10 2:18 PM, Mike Driscoll wrote:

> On Apr 5, 3:26 pm, Mark Reed<markree...@gmail.com> wrote:
>> Attached is a sample app that is confusing me. It is a notebook whose
>> pages contain 2 panels - a parent and a child. Tab from the notebook
>> tabs causes focus to appear on the child. Tab or right arrow does
>> nothing while Tab backwards puts focus back on the notebook.

>> Why doesn't the focus appear initially on the parent panel which was
>> created first?

> Probably because panels cannot accept focus if they have children that
> can accept focus.

Just a technicality, but they do accept focus, they just immediately
pass it on to their child if they have any.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org