Discussion:
[fc] getting x,y position when a click on an object
Nouvelle Collection
2014-02-11 14:09:19 UTC
Permalink
Hello,

I create an image on a Canvas with:
myimg = self.Canvas.AddScaledBitmap(img, (x,y), Height=img.GetHeight(),
Position = 'tl')
myimg.Bind(FloatCanvas.EVT_FC_RIGHT_DOWN, self.OnShowPopupMenu)

When OnShowPopupMenu is called, the "myobj" parameter don't give the
position where the click has been done :

def OnShowPopupMenu(self, myobj):
event = ? # how to get the event here ?
pos = event.GetPosition()
pos = self.panel.ScreenToClient(pos)
self.panel.PopupMenu(self.popupmenu, pos)

How would you find the place where the click has been done when
EVT_FC_RIGHT_DOWN occurs ?

Best regards, J
Chris Barker
2014-02-11 17:48:27 UTC
Permalink
I really need to work on docs...
Post by Nouvelle Collection
myimg = self.Canvas.AddScaledBitmap(img, (x,y), Height=img.GetHeight(),
Position = 'tl')
myimg.Bind(FloatCanvas.EVT_FC_RIGHT_DOWN, self.OnShowPopupMenu)
When OnShowPopupMenu is called, the "myobj" parameter don't give the
event = ? # how to get the event here ?
pos = event.GetPosition()
pos = self.panel.ScreenToClient(pos)
self.panel.PopupMenu(self.popupmenu, pos)
How would you find the place where the click has been done when
EVT_FC_RIGHT_DOWN occurs ?
myobj should have two attributes:

myobj.HitCoords ==== the 'world' coordinates where the mouse was

myobj.HitCoordsPixel === the coords in pixels (relative to the Panel, Im
pretty sure)


-Chris
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker-***@public.gmane.org
Nouvelle Collection
2014-02-11 20:36:43 UTC
Permalink
It works perfectly ! Thank you Chris ! J
Post by Chris Barker
I really need to work on docs...
Post by Nouvelle Collection
myimg = self.Canvas.AddScaledBitmap(img, (x,y), Height=img.GetHeight(),
Position = 'tl')
myimg.Bind(FloatCanvas.EVT_FC_RIGHT_DOWN, self.OnShowPopupMenu)
When OnShowPopupMenu is called, the "myobj" parameter don't give the
event = ? # how to get the event here ?
pos = event.GetPosition()
pos = self.panel.ScreenToClient(pos)
self.panel.PopupMenu(self.popupmenu, pos)
How would you find the place where the click has been done when
EVT_FC_RIGHT_DOWN occurs ?
myobj.HitCoords ==== the 'world' coordinates where the mouse was
myobj.HitCoordsPixel === the coords in pixels (relative to the Panel, Im
pretty sure)
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
_______________________________________________
FloatCanvas mailing list
http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
Continue reading on narkive:
Loading...