to example # when the mouse moves, go to the next position if readmouse=0 [setpos mousepos] example endIn this second procedure, it's the same but you must click with the left button of the mouse if you want the turtle to move.
to example2 if readmouse=1 [setpos mousepos] example2 endIn this third example, we create two pink buttons. If we left-click on the left button, we draw a square with a side of 40. if we left-click on the right button, we draw a little circle. Last, if we right-click on the right button, it stops the program.
to button #create a pink rectangular button (height 50 - width 100) repeat 2[fd 50 rt 90 fd 100 rt 90] rt 45 pu fd 10 pd setpc [255 153 153] fill bk 10 lt 45 pd setpc 0 end to lance cs button pu setpos [150 0] pd button pu setpos [30 20] pd label "Square pu setpos [180 20] pd label "Circle pu setpos [0 -100] pd mouse end to mouse # we put the value of readmouse in the variable ev make "ev readmouse # we put the first coordinate of the mouse in variable x make "x item 1 mousepos # we put the second coordinate of the mouse in variable y make "y item 2 mousepos # When we click on the left button if :ev=1 & :x>0 & :x<100 & :y>0 & :y<50 [square] # When we click on the right button if :x>150 & :x<250 & :y>0 & :y<50 [ if :ev=1 [circle] if :ev=3 [stop] ] mouse end to circle repeat 90 [fd 1 lt 4] lt 90 pu fd 40 rt 90 pd end to square repeat 4 [fd 40 rt 90] rt 90 fd 40 lt 90 end