[wxPython] pgUp,Down in wxScrolledWindow

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] pgUp,Down in wxScrolledWindow

Udo Floegel
Hallo,

yes PageUp/Down works, if the window has the focus.
But when controls are in it, how to scroll the window?
When a embedded control has the focus so the PgUp
is for the parent lost.
A Combobox uses also PgUp/Down for its own list, the
cursor keys work in a radiobox (as expected).
What is the way for scrolling such a construction ?

(tab-traversing in wxScrolledWindow works (only) with wxTAB_TRAVERSAL,
which is for wxPanel not necessary).


regards, Udo


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] pgUp,Down in wxScrolledWindow

Robin Dunn
> yes PageUp/Down works, if the window has the focus.
> But when controls are in it, how to scroll the window?
> When a embedded control has the focus so the PgUp
> is for the parent lost.
> A Combobox uses also PgUp/Down for its own list, the
> cursor keys work in a radiobox (as expected).
> What is the way for scrolling such a construction ?
>
> (tab-traversing in wxScrolledWindow works (only) with wxTAB_TRAVERSAL,
> which is for wxPanel not necessary).
>
>


You can probably solve this (and the autoscroll when you move to a hidden
control) with just a bit of work.

First create a class derived from wxEvtHandler and set it to handle
EVT_SETFOCUS and EVT_KEYDOWN events.  Push an instance of this class onto
every control you put on the scrolled window using control.PushEventHandler.
This allows your event handler class to get the key and focus events before
the control does.

In the handler for EVT_SETFOCUS determine if the control is visible based on
the current view of the scrolled window and scroll it if not.

In the handler for EVT_KEYDOWN there are two approaches you can take.  The
first is to pass all key events to the scrolled window it see if it wants to
handle them, if not then let the control get the event.  You can do that with
something like this:

    handler = self.theScrolledWindow.GetEventHandler()
    if not handler.ProcessEvent(event):
        event.Skip()

The other approach is to only pass events for PgUp/PgDn keys to the scrolled
window and call event.Skip() for everything else.

Let us know how this works for you.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!


just call event.Skip() if the key is not


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users