Closed GoogleCodeExporter closed 9 years ago
In console:
>>> p2 = Pynguin()
In code area:
def onclick(x, y):
p2.goto(x, y)
Click "Test" button.
If you have a proposal for a better way to do this, I'm willing to listen.
Original comment by miss...@hotmail.com
on 13 Jun 2010 at 2:08
Perhaps each sprite can have its own activate_click_listener method that
defines onclick?
Original comment by aresnick...@gmail.com
on 13 Jun 2010 at 4:39
Give the most recent a try.
By default, all pynguins will now respond to mouse clicks.
The signature for onclick() definitions has changed -- It is now a class method
instead of a plain function and requires a first parameter (self).
You can write a subclass with an overridden onclick() method, or make a
monkeypatch. See the onclick examples for details.
Also, each pynguin can stop (or start again) listening for clicks by setting
the respond_to_mouse_click variable:
p.respond_to_mouse_click = False # stop listening
p.respond_to_mouse_click = True # start listening again
Would it be useful to have right-click set the clicked pynguin to respond and
unset all of the others? Or maybe there could be a menu with a list of all the
pynguins and a check next to the one that will respond to mouse clicks. (with
an "All" choice selected by default).
Original comment by miss...@hotmail.com
on 13 Jun 2010 at 6:09
Original issue reported on code.google.com by
aresnick...@gmail.com
on 13 Jun 2010 at 1:11