[wxPython] Generate virtual mouse click at x,y

hi.

hmm, i think that i probably need an english lesson
to check out what i'am reading at the online docs.
perhaps it is my minor understanding of the
window managment system in wx.
And so there questions over q. The very difficult (to me)
i post here. i hope these posts are not too much...
this time my question is simple, i think so...

i have a dialog without a caption, a (staticbox)sizer on it,
which owns one TextCtrl, and 3 BitmapButtons (one to close
the dialog).

if the dialog popups the user should have 2 chioces.

1. click anywhere, but not in the dialog to close the dialog
2. click in the dialog to change the contents

self.commentwin is the dialog

Step one.
i've give the dialog (not the sizer or anything in it) the mouseinputs

self.commentwin.CaptureMouse()

if the user clicks somewhere, what he must do to work on :wink: an
function called which check if the click was inside or outside
the rect of the dialog...

EVT_LEFT_DOWN(self.commentwin, self.WhatTheUserWant)

def WhatTheUserWant(self,event):
        if self.checkifoutside(event.GetPosition()):
            self.commentwin.ReleaseMouse()
            self.commentwin.EndModal(self.commentwin.GetReturnCode())
        else:
            self.commentwin.ReleaseMouse()
               ###### HERE MUST STAND IT #######
        event.Skip()

Here is the problem. if the user clicks in the dialog, the !one! click
releases the mouse. if the user clicks direct on a button with the first
click, nothing happen, only the mouse has been released, what the user
don't know. So its a little bit confusing to him...

I tried some thingz but nothing works...

Question:
What should i do to let the user clicks one time in the dialogbox and
let him get the result of the click? To Release the mouse and pass the
event to Whatever he's clicking at? Or should i try another way to
reach this solution?

Hmmm, can you write so, that i understand it easily?

Thx, reen <-is a german kid

Rene Freund
rene@meder.de

Question:
What should i do to let the user clicks one time in the dialogbox and
let him get the result of the click? To Release the mouse and pass the
event to Whatever he's clicking at?

If you can figure out from the coordinants of the click which control would
normally receive the event, then you can do something with it.
Unfortunately you can't send the event to the native control as it knows
nothing about the wxEvents, so you won't be able to make it do the normal
things like getting an indented look, or sending the right command event for
EVT_BUTTON to catch...

On the other hand, you could use the generic buttons in
wxPython/lib/buttons.py and then forward mouse events to it using the normal
wx event dispatching mechanisms. For example, something like this using
wxGenBitmapButton might work:

def WhatTheUserWant(self,event):
        if self.checkifoutside(event.GetPosition()):
            self.commentwin.ReleaseMouse()
            self.commentwin.EndModal(self.commentwin.GetReturnCode())
        else:
            # Find which button the click is on.
            button = self.FindButton(event.GetPosition())
            if button:
                 # translate coordinantes from parent position to button
position
                 x, y = self.MakeButtonCoordinants(event.GetPosition())

                 # resend the event to the button
                 event.m_x = x
                 event.m_y = y
                 button.GetEventHandler().ProcessEvent(event)
        event.Skip()

You will probably need to do this for EVT_LEFT_DOWN, EVT_LEFT_UP, and
EVT_MOTION.

···

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