Robin Dunn wrote:
raf wrote:
>Robin Dunn wrote:
>>* Not all widgets will accept the focus, if not then they are just
>>skipped when looking for the next item in the order. Widget classes can
>>control this by overriding the AcceptsFocus method (unfortunately in
>>wxPython it is only overridable in the wx.Py classes like wx.PyControl.)
>
>the widget that wouldn't accept focus was a TextCtrl so it
>should. i fixed that by taking it out of the StaticBoxSizer
>that it was in. that was the only difference between it and
>the other widgets. it doesn't look at good now but that's
>less important.
The focus was probably actually stuck in some widget before the TextCtrl
in the tab order.
>>Not to your specific example... The first problem is that you are
>>specifying style=wx.BORDER_SUNKEN for your panels. There's no problem
>>with the border itself, it's the fact that you are no longer using the
>>default style of wx.TAB_TRAVERSAL. Change them to be
>>style=BORDER_SUNKEN|wx.TAB_TRAVERSAL instead. Once you do that then
>>when the focus is in the tree and tab is pressed, the traversal code
>>will look up to the splitter window which will then go to the right-side
>>panel which will then give the focus to the AuiNotebook.
>
>strangely enough, that isn't what happened. the focus still
>didn't return to the right hand side. i tried removing the
>panel between the splitter window and the auinotebook as
>well but that didn't change anything either.
It did fix it on Windows in my tests, but the fact that there's a
perhaps the windows i'm using (nt4) is too old to be indicative.
platform difference here doesn't surprise me too much. Also, on Mac the
ability to tab to some types of widgets is turned off by default, and
needs to be turned on using the Full Keyboard Access option in System
Preferences.
i did have 'Full Keyboard Access' turned on.
>since i really wanted tabbing to cycle within a single
>auinotebook pane anyway (and use something like Ctrl-Tab
>to move between panes), i decided to take over the tabbing
>myself.
>
>based on your responses to others in the archives, i
>attempted this by preventing TAB_TRAVERSAL everywhere and
>using WANTS_CHARS and TE_PROCESS_TAB in all the relevant
>widgets. there was a problem with that on macosx (i.e.
>ComboBox doesn't receive EVT_CHAR events for tab characters)
>but that was easily resolved (because it does receive
>EVT_KEY_DOWN events for tab characters). it now works fine
>on macosx and linux (where comboBoxreceives both
>EVT_KEY_DOWN and EVT_CHAR events for tab characters) but
>doesn't work at all on windows where ComboBox doesn't
>receive either event for tab characters (this is without
>TAB_TRAVERSAL and with WANTS_CHARS|TE_PROCESS_TAB of course).
>
>so on windows(nt), tabbing stops at the first ComboBox
>and goes no further. windows(xp) is the system that it
>really needs to work on.
>
>can you suggest what i might do to resolve that? i'm hoping
>it's something simple.
Adding something like this will help you debug it and maybe help with
finding a workaround:
global cl
def showfocus():
print wx.Window.FindFocus()
cl.Restart()
cl = wx.CallLater(3000, showfocus)
I'm not sure why but it looks like focus is going to the AuiNotebook
when tab is pressed in a combobox.
--
Robin Dunn
Software Craftsman
thanks. that was very helpful.
So that means that turning off TAB_TRAVERSAL doesn't work on Windows.
Or at least when there's an AuiNotebook and ComboBoxes or Buttons involved.
I set up an EVT_SET_FOCUS for the AuiNotebook but since the actual Tab
keystroke event is lost, it can't tell if it was Tab or Shift-Tab.
So, using this approach, it's possible to make Tab cycle through the controls
within an AuiNotebook page but you can't reliably get Shift-Tab to work as well.
What I had to do, to make it work on Windows, was to make Tab and Shift-Tab
accelerators. That seemed a little extreme but it worked completely.
I had already made Ctrl-Tab and Shift-Ctrl-Tab cycle through AuiNotebook
pages by making them accelerators. In doing so, I discovered that, on
Linux, Tab can't be used as an accelerator. If you try, it can show up
in menus as though it was working but the accelerator handler isn't called.
Instead, EVT_KEY_DOWN events are generated.
I also noticed that without TAB_TRAVERSAL and with WANTS_CHARS, on MacOSX,
ComboBoxes don't receive EVT_CHAR events when Tab is pressed but they do
receive EVT_KEY_DOWN events.
I came across other inconsistencies so, below is a list of
what-look-to-me-to-be-platform-specific-bugs.
Would you agree? Should I enter bug reports for each of these?
The attached program demonstrates them. By changing the flags
at the top of the program, either the incomplete hack or the
complete hack can be demonstrated as well.
many thanks,
raf
List of platform-specific bugs
wx-platform-inconsistencies.py (40.5 KB)
···
------------------------------
MacOSX Platform: macosx-10.4.11, python-2.5.2, wxpython-2.8.8.1 (mac-unicode)
Linux Platform: linux-2.6.24, python-2.5.2, wxpython-2.8.7.1 (gtk2-unicode)
Windows Platform: nt4sp6, python-2.5.2, wxpython-2.8.8.1 (msw-unicode)
1. On Windows, disabling TAB_TRAVERSAL and using WANTS_CHARS doesn't
work with ComboBoxes or Buttons that are inside an AuiNotebook. I
don't know if the presence of the AuiNotebook is relevant but when
the Tab key is pressed while focus is in a ComboBox or Button, there
is no EVT_CHAR event as there should be. Instead the focus moves to
the AuiNotebook itself and is lost to the user (until they click).
2. On Windows, ComboBox controls receive two EVT_SET_FOCUS events
when they receive focus instead of just one.
3. On MacOSX, ComboBox and TextCtrl don't receive EVT_SET_FOCUS events
like on other platforms. Instead they receive EVT_CHILD_FOCUS events.
4. On MacOSX, without TAB_TRAVERSAL and with WANTS_CHARS, ComboBox
doesn't get EVT_CHAR events for Tab keys as it should but it does
get EVT_KEY_DOWN events.
5. On Linux, the Tab key can't be used in an accelerator, with or
without modifiers. They can appear in menus as accelerators but
when the Tab key is pressed, EVT_KEY_DOWN events are generated.
The appropriate menu handler is not called.
6. On linux, if a ComboBox has selected text, and the user types a character,
there are two EVT_TEXT events generated. The first has the text with the
selected text absent. The second has the text with the new character present.
On MacOSX and Windows, this all happens with a single EVT_TEXT event being
generated. This makes auto-completing controls more difficult.