[wx-dev] [all] scrolled windows and panels
Vadim Zeitlin
vadim at wxwindows.org
Thu Apr 5 02:56:51 PDT 2007
On Thu, 05 Apr 2007 09:13:31 +0100 Julian Smart <julian at anthemion.co.uk> wrote:
JS> In my StoryLines app I have a class derived from wxScrolledWindow which
JS> for the most part doesn't have children, and must accept the focus. But
JS> sometimes a temporary control will be created on the window to allow
JS> text editing in situ. Which scrolled window would I choose? I guess
JS> wxScrolledControl, so that it accepts focus, and I would have to deal
JS> with tab traversal myself if required.
Sorry, I don't understand: why would you need tab traversal at all in this
case? When it doesn't have children, there is nothing to traverse and when
it shows the embedded text control there is only one child and pressing TAB
usually hides it anyhow. So while I agree that you would probably use
wxScrolledControl/Canvas I don't quite understand why should you deal with
tab traversal at all?
JS> Couldn't we just have a style and/or accessor to change the tab
JS> traversal behaviour?
This is incompatible with the existing AcceptsFocus(): if we had a
"accepts focus" flag in wxWindow, overriding AcceptsFocus() in derived
classes would stop working (worse, it would silently stop working).
JS> I do think that making the user choose between two similarly-named
JS> classes is going to introduce undesirable complexity, which I'd like to
JS> see avoided if possible. (I can see that deriving from a panel is
JS> conceptual overkill in some cases, but the advantage is simplicity of
JS> API and reduced confusing choice.)
OTOH if you keep a single wxScrolledPanel (current wxScrolledWindow)
class, you would have to do something to indicate that the control needs
focus for itself, it seems to be impossible to do it automatically (the
only heuristics I can think of is to accept focus in the window itself only
if it has at most one child accepting focus itself -- but this is already
quite complex and still probably doesn't cover all cases). While just by
deriving from wxScrolledCanvas/Control it would be taken care of.
I do believe there is a fundamental difference between wxPanel, which is a
control container, and a window which may happen to contain other windows
but is mostly used for something else. And I don't see any simple way to
make the same wxPanel class (via wxScrolledWindow) behave in both ways at
once.
Regards,
VZ
More information about the wx-dev
mailing list