[wxpython-users] AcceptsFocusFromKeyboard help

Paul M¢Nett p at ulmcnett.com
Fri Apr 4 12:30:50 PDT 2008


Robin Dunn wrote:
> Paul M¢Nett wrote:
>> What I'm trying to do is to make a generic property, TabStop, that when
>> True will allow the control to receive focus from keyboard navigation,
>> and if False will not. I could see a semi-complex route of catching the
>> SET_FOCUS event and then trying to figure out how the focus was gotten,
>> from what direction, etc. and pass the focus to the next control, 
> 
> You can use the Navigate method to make that a little easier.  Watching 
> for EVT_NAVIGATION_KEY events may also help.

The Navigate() method appears to usually do exactly what I want, without 
even having to tell it which direction to go in even. However I'm 
running into trouble when at a "border": when the control that catches 
the event is the last control in the panel, for instance, or when no 
controls in the panel should receive focus.

Since you are hinting that I'm on the right path, I'll continue with 
implementing this by catching EVT_NAVIGATION_KEY and selectively 
skipping the event or calling Navigate(). When I have specific testable 
problems I'll post them here.

>> but if
>> there's some way I could instead override AcceptsFocusFromKeyboard that
>> would be the cleaner solution.
> 
> There isn't a way to do that now, but in 2.9 there will be a SetCanFocus 
> method.

Excellent news!

Paul



More information about the wxpython-users mailing list