MCPcopy Index your code
hub / github.com/python/cpython / _onscreenclick

Method _onscreenclick

Lib/turtle.py:652–668  ·  view source on GitHub ↗

Bind fun to mouse-click event on canvas. fun must be a function with two arguments, the coordinates of the clicked point on the canvas. num, the number of the mouse-button defaults to 1 If a turtle is clicked, first _onclick-event will be performed, then _ons

(self, fun, num=1, add=None)

Source from the content-addressed store, hash-verified

650 self.cv.tag_bind(item, "<Button%s-Motion>" % num, eventfun, add)
651
652 def _onscreenclick(self, fun, num=1, add=None):
653 """Bind fun to mouse-click event on canvas.
654 fun must be a function with two arguments, the coordinates
655 of the clicked point on the canvas.
656 num, the number of the mouse-button defaults to 1
657
658 If a turtle is clicked, first _onclick-event will be performed,
659 then _onscreensclick-event.
660 """
661 if fun is None:
662 self.cv.unbind("<Button-%s>" % num)
663 else:
664 def eventfun(event):
665 x, y = (self.cv.canvasx(event.x)/self.xscale,
666 -self.cv.canvasy(event.y)/self.yscale)
667 fun(x, y)
668 self.cv.bind("<Button-%s>" % num, eventfun, add)
669
670 def _onkeyrelease(self, fun, key):
671 """Bind fun to key-release event of key.

Callers 1

onclickMethod · 0.80

Calls 2

unbindMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected