Hi all,
My UI has this layout
Menu Bar
Panel 1: some buttons and radio buttons
Panel 2: An image in a StaticBitmap; then a vertical BoxSizer containing some additional buttons, dropdowns, and a text box
Panel 3: More buttons
The user can draw various specific markups on the image using the mouse. I would also like for certain keypresses to be processed by the image panel. This has limited success so far. When initialized, focus is set on the panel containing the StaticBitmap. The panel’s event handler reads thus
def OnKeyDown(self, event):
if self.inWindow: # flag set True when mouse enters StaticBitmap, False when mouse exits
print("key down", event.GetKeyCode())
if self.state == "box":
if self.currentBox.state == "rotating":
if event.GetKeyCode() == wx.WXK_LEFT:
self.currentBox.Rotate(-Box.DELTA_ANGLE)
elif event.GetKeyCode() == wx.WKX_RIGHT:
self.currentBox.Rotate(Box.DELTA_ANGLE)
event.Skip()
When various keys are pressed, I get appropriate output “key down 65”, etc. … until I hit an arrow key. Then the buttons and/or text box gets the focus, and no amount of mouse-clicking or keystroking can return the focus to the panel. As an experiment, I tried disabling keyboard focus on each button and text box; no joy. I also tried splitting the middle panel into two separate panels. No joy and it looked uglier.
Any advice on how to do this right?
Thanks,