igormarfin / mplh5canvas

Automatically exported from code.google.com/p/mplh5canvas
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

matplotlib's button widget doesn't respond to initial button-click (trivial fix supplied) #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a button and an event listener, called when button is clicked
2. click the button
3. check if your event-listener gets called

What is the expected output? What do you see instead?
button_click_event should be triggered when button is clicked, but is only 
triggered after button is clicked and then another click is done (on button or 
something else).

What version of the product are you using? On what operating system?
Current svn version (rev 32)

Please provide any additional information below.
The fix is trivial:
in handle_click(...) in backend_h5canvas.py the button_press and button_release 
events get called in the wrong order (release, press), so only after a second 
click a (release),press->release,(press) cycle triggers the "clicked" event. If 
I change the order and call first button_press_event and then 
button_release_event the events are processed as expected: A button click 
triggers my event directly.

So the handle_click function should be changed to:

def handle_click(self, x, y, button):
  self.button_press_event(float(x), float(y), int(button))
  self.button_release_event(float(x),float(y),int(button))

Thanks for this very useful piece of software!

  Christoph

Original issue reported on code.google.com by Prof.T...@gmail.com on 1 Dec 2011 at 9:32

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r33.

Original comment by ludwig.s...@gmail.com on 29 Jun 2012 at 2:53