[wxPython] Mouse down not seen by frontmost child (Win2K wxp2.3.0)

I'm trying to create a simple frame containing a panel with a background
bitmap and a text control. While the text control is visible and can be
typed into it does not see mouse down or mouse drags. The code looks like:

from wxPython.wx import *

class CardFrame(wxFrame):
        def __init__(self):
                wxFrame.__init__(self, None, -1, "NotACard",
                        size = (320, 320),
                        style = wxDEFAULT_FRAME_STYLE |
                        wxNO_FULL_REPAINT_ON_RESIZE)
                self.panel = wxPanel(self,1)
                image = wxEmptyImage(80, 80)
                bmp = image.ConvertToBitmap()
                self.bitmap = wxStaticBitmap(self.panel, -1, bmp,
                        wxPoint(0, 0),
                        wxSize(bmp.GetWidth() * 4,
                        bmp.GetHeight() * 4))
                self.text = wxTextCtrl(self.panel, -1, "",
                        wxPoint(50, 50), wxSize(200, 200),
                        wxTE_MULTILINE)

class MyApp(wxApp):
        def OnInit(self):
                frame = CardFrame()
                frame.Show(true)
                self.SetTopWindow(frame)
                return true

app = MyApp(0)
app.MainLoop()

   Reversing the creation of the text and bitmap controls leads to the text
being invisible (mostly - it appears when typing) but able to accept mouse
downs. Running Spy++ shows that a mouse down results in a WM_GETDLGCODE
message but no mouse messages. On windows normally window get all the mouse
events wherever they are visible but wxWindows seems to invert this so the
messages go to the wrong window.

   Neil

   Reversing the creation of the text and bitmap controls leads to the

text

being invisible (mostly - it appears when typing) but able to accept mouse
downs. Running Spy++ shows that a mouse down results in a WM_GETDLGCODE
message but no mouse messages. On windows normally window get all the

mouse

events wherever they are visible but wxWindows seems to invert this so the
messages go to the wrong window.

Up until recently the answer to overlaping controls in wxWindows was "don't
do it." 2.3.x has the wxCLIP_SIBLINGS flag that helps, but it's still not
entirly intuitive. The flag didn't make it into wxPython 2.3.0, but you can
set the calue yourself like this:

wxCLIP_SIBLINGS = 0x20000000

This works:

class CardFrame(wxFrame):
        def __init__(self):
                wxFrame.__init__(self, None, -1, "NotACard",
                        size = (320, 320),
                        style = wxDEFAULT_FRAME_STYLE |
                        wxNO_FULL_REPAINT_ON_RESIZE)
                self.panel = wxPanel(self,1)
                image = wxEmptyImage(320, 320)
                bmp = image.ConvertToBitmap()
                self.text = wxTextCtrl(self.panel, -1, "",
                        wxPoint(50, 50), wxSize(200, 200),
                        wxTE_MULTILINE)
                self.bitmap = wxStaticBitmap(self.panel, -1, bmp,
                        wxPoint(0, 0),
                        wxSize(bmp.GetWidth(),
                        bmp.GetHeight()), wxCLIP_SIBLINGS)

BTW, if all you are wanting to do it put an image in the background then a
better way to do it is to catch the EVT_ERASE_BACKGROUND event and draw the
image there, without using a wxStaticBitmap. See demo/wxDragImage.py or
demo/ColourDB.py for examples.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!