Intercept and modify MouseEvents?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Intercept and modify MouseEvents?

cblot
In wxPython2.8 I was able to modify MouseEvents.
This would change the MouseEvent's x,y position to parent coordinates and allow them to propagate to the parent.

    def OnClick(self, event):
        screen = self.ClientToScreenXY(*event.GetPositionTuple())
        event.m_x, event.m_y = self.parent.ScreenToClient(screen)
        event.SetEventObject(self.parent)
        event.ResumePropagation(1)
        event.Skip()

In wxPython 3.0 this raises a wxPyDeprecationWarning: Accessing deprecated property.
If I change the line to:
        event.X, event.Y = self.parent.ScreenToClient(screen)
Then it works fine, but this doesn't work at all under wxPython2.8 (unable to set property).

Is there a better way to do this? Something that would work under all wxPython versions?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Intercept and modify MouseEvents?

firefox
do you actually have customers demanding "backwards compatibility" ?

Else just progam against "Phoenix".

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Intercept and modify MouseEvents?

jamesw
Hi,

If you can use only Phoenix, that's great, but if you want to support both Classic and Phoenix for now, while Phoenix is still in alpha, you can run different code for Classic and Phoenix, like this:

if 'phoenix' in wx.PlatformInfo:
    event.X, event.Y = self.parent.ScreenToClient(screen)
else:
    event.m_x, event.m_y = self.parent.ScreenToClient(screen)

Disclaimer: I'm not familiar with the ScreenToClient method - I'm only commenting on the desire to have your code run against both Classic and Phoenix without deprecation warnings.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...