views:

24

answers:

2

So, for example I draw some objects on wx.PaintDC, such as lines and rectangles. Now I want next: on mouse click I wont know which object was clicked. Of course, I can see what object is the closest, but what about more exact answer?

Maybe even not standart wx.DC, but such things as FloatCanvas or something like this.

So, what's the best solution?

A: 

You can use a PseudoDC and its FindObjects method

In my drawing program, Whyteboard I employ a whole bunch of maths, polymorphic classes and such to allow users to "hit test" drawn items with the Select drawing tool.

You can also do this with FloatCanvas, it provides HitTest(x, y) (off the top of my head) methods that should do what you want. But, I'm not sure how hard it'll be for you to convert your application to use it.

Steven Sproat
A: 

Does calling event.GetEventObject() in your event handler give you the object you need?

Mike Driscoll