Stef Mientki wrote:
hello,
I've got it all working,
but I wonder if this is the right way to do it,
and if there are easier ways to do it.I'm using a ScrolledWindow for drawing.
Now I want to catch the keyboard events in the ScrolledWindow,
but unfortunately the ScrolledWindow can't get focus
(at least that's what I guess what happens
The rule for wx.Panel (and wx.ScrolledWindow since it derives from it) when it gets the focus is to check and see if there is a child widget that can accept the focus, and either transfer the focus to the last child that had the focus, or the first one that can accept it. Otherwise it keeps the focus for itself.
Now I have created an extra wx.Window,
which is invisible, because a CustomTreeCtrl is drawn over it.
As soon as I click on the CustomTreeCtrl,
I force focus to the hidden wx.Window.The hidden wx.Window although invisible,
gets focus and catches the key events,
which I can then use to perform actions in my ScrolledWindow.
Why not just handle the key events in the CustomTreeCtrl?
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!