myself, I'm all for (1). similarity with wx would make it easier to
learn & work with, IMO.
fixing existing code to work with it would be trivial.
thanx,
ryan
Christopher Barker wrote:
Tim Ansell wrote:
I've been playing with the MouseOver/Click events in FloatCanvas and
have run into a little problem.
The bound methods only get called with the object and not the wxPython
event which caused them.
Yes, this was my way of trying to nifty.
This means that you can't do things like check
if Shift was down when the mouse was clicked
Darn. That's a key missing feature. It's been suggested on this list
before that the object events really should have the same API as other
wx events -- i.e. passing an event object into the callback, rather than
the object.
It looks like it would be trivial to change the methods so that they can
be called with the event,
But you do want info about the object in there too.
I propose two possibilities:
1) Have the callback receive a FloatCanvas._MouseEvent, but with an
extra attribute for the object that generated the event (it's not a
wx.Window, so we can't use exactly the same API). This would be much
like the events generated by FloatCanvas when you haven't hit an object.
Indeed, it would make the API the same, you could always check if
event.Object was None, and you'd know that no object had been hit. This
would break backwards compatibility, but wouldn't be hard to fix:
def CallBack(self, Object):
Would become:
def CallBack(self, event):
Object = event.ObjectHit
2) Still pass the Object, but put the event in there as an attribute, so
you could do:
def CallBack(self, Object):
Event = Object.Event
3) Really change things. It's been suggested that rather than binding to
DrawObjects, we should just catch the event on the Canvas, and call
Canvas.WhatObjectsAreHit() method or something. That gives the
programmer a bit more flexibility and control, but takes away the
convenience of simply binding a callback to an event on an object. Of
course, we could probably add this, without removing the existing system.
(1) would be a cleaner API -- more compatible with the rest of wx
(2) would work, be less code to implement (it looks like one line!), and
be backward compatible, but ultimately not be really the "right" API.
(3) is going to take more discussion, as it's a more significant change.
Any thoughts? -- Most importantly, how annoyed would everyone be if we
changed the API to (1)?
-Chris
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas