Slaying the focus demons...

Okay, I've just completed a re-implementation of the wxControlContainer mechanism in Python, with some refactoring to allow easy sub-classing. I've created a sub-class with the ability to set an explicit tabbing order among the children of a window. This should allow you to build reusable controls which properly handle:

    * re-setting the current control on re-focus, * tabbing through controls in an explicitly-defined order
          o by default all controls in creation order, as with
            wxPython's base version, o you can explicitly set a different order, or exclude certain
            controls from the set,
          o you can change the "focus" set at run-time (i.e. remove
            certain controls from the set in response to changes to
            data-values so that order-of-focus operates naturally),
          o a sub-class could decide to implement "geometric" order if
            desired (i.e. the order follows the positions on-screen),
    * chaining up/down from parent controls to sub-controls and vice-versa.

There are likely still some bugs in there, but the basic operation seems correct. (As much as practical, this follows the wxWindows algorithm (the code is a direct translation of the C++ code)).

Enjoy all,
Mike

wxcontrolcontainer.py (14.2 KB)

···

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

For those of you following along at home. I'm still working on this (fixing bugs as I integrate it with the various controls in wxoo). If you want the latest version, it's in the wxoo CVS tree as wxoo/wxcontrolcontainer.py

Enjoy,
Mike

Mike C. Fletcher wrote:

Okay, I've just completed a re-implementation of the wxControlContainer mechanism in Python, with some refactoring to allow easy sub-classing. I've created a sub-class with the ability to set an explicit tabbing order among the children of a window. This should allow you to build reusable controls which properly handle:

...