Reputation: 33
I want to detect the difference of position between when I left-click in a panel and when I finish clicking (when the left button goes up after the click). I detect correctly the click and I know how to get the position of the mouse but I don't know how to detect when the click ends This is how I associate the event of the left-click to the panel:
x = wx.Panel(self, wx.ID_ANY)
x.SetBackgroundColour(wx.Colour(self.colores[aux2[1]]))
x.SetMinSize((20,20))
x.Bind(wx.EVT_LEFT_DOWN, self.onClick)
This is the event handler:
def onClick(self, event):
if (self.modo == 'jugando'):
print('click')
And this is the output of the program:
click
So I know that I enter correctly in the handler but I don't know how can I detect when the left button of the mouse goes up afther this
Upvotes: 1
Views: 74
Reputation: 96
I would do it this way:
x = wx.Panel(self, wx.ID_ANY)
x.SetBackgroundColour(wx.Colour(self.colores[aux2[1]]))
x.SetMinSize((20,20))
x.Bind((wx.EVT_MOUSE_EVENTS, self.onMouseEvent)
Event handling:
def onMouseEvent(self, event):
if event.LeftDown():
self.previous_position = event.Position
elif event.LeftUp():
self.current_position = event.Position
...
Upvotes: 1