Using The Mouse To Create Graphics


Let's try to write a short Pro-SiMPLE program that will read the mouse and, if the left button is pressed, draw a solid circle of radius 25 pixels at the current mouse location:

       Int mx, my, button
       graph on
       show mouse
       Do
          read mouse (mx, my, button)
          If (button=1) solid circle (mx, my, 25)
          read quitkey
       Loop

When the program starts, the screen will be blank (except for the mouse cursor). Carefully, without moving the mouse, momentarily press the left mouse button. A solid circle will appear. (So far, so good.) But now carefully release the button, and then move the mouse away. Suddenly the circle has a hole in it where the mouse cursor used to be!

Whenever you write a Pro-SiMPLE program that uses the mouse to create graphics, you must always remember to use the hidemouse task to temporarily remove the mouse cursor prior to drawing:

       Int mx, my, button
       graph on
       show mouse
       Do
          read mouse (mx, my, button)
          If (button=1)
             hide mouse
             solid circle (mx, my, 25)
             show mouse
          Endif
          read quitkey
       Loop



  [ Webmaster | FAQ's | Home Page | Contact Us ]