LESSON+7



 **//SEQUENTIAL STRUCTURES: GRAPHICAL USER INTERFACE//**
 Mouse commands allow you to create programs with a Graphical User Interface (GUI), this means you can have clickable buttons. Here are the basic mouse commands.


 * Mouse.where (x, y, button) ||  ||   ||
 * Mouse.ButtonMoved(motion) ||  ||   ||
 * Mouse.ButtonWait (motiont, x,y,buttonnumber, buttonUpDown) ||  ||   ||

Here is an example of how they work.  **1) Mouse.Where**


 * setscreen ("graphics:120;120,nobuttonbar,position:center;center") %the setscreen commands just position the screen **
 *  var x, y, button : int **
 *  var r := 60 **
 *  loop **
 *  Mouse.Where (x, y, button) **
 *  if button = 0 then **
 *  drawfilloval (60, 60, r, r, blue) **
 *  end if **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> if button = 1 and x 2 + button 2 <= r 2 then **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> drawfilloval (60, 60, r, r, red) **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end if **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end loop **

or this one


 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;">var x, y, button : int **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> loop **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> cls **
 * <span style="color: #000080; font-family: 'Courier New',Courier,monospace; font-size: 140%;"> Mouse.Where (x, y, button) **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> locatexy (10, 50) **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> put x:10, button:10 **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end loop **

2) Mouse.ButtonWait
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;">var x, y, buttonnumber, buttonUpDown : int **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> loop **
 * <span style="color: #000080; font-family: 'Courier New',Courier,monospace; font-size: 140%;"> Mouse.ButtonWait ("down",x, y, buttonnumber, buttonUpDown) **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> drawoval (x,y, 20,20,red) **
 * <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end loop **

<span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;">3)Mouse.ButtonMoved <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;">var x, y, buttonnumber, buttonUpDown : int <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> loop <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> if Mouse.ButtonMoved ("up") then <span style="color: #000080; font-family: 'Courier New',Courier,monospace; font-size: 140%;"> Mouse.ButtonWait ("up", x, y, buttonnumber, buttonUpDown) <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> drawfillbox (x, y, x+20, y+20, brightgreen) <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> elsif Mouse.ButtonMoved ("down") then <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> Mouse.ButtonWait ("down", x, y, buttonnumber, buttonUpDown) <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> drawfilloval (x, y, 20, 20, red) <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end if <span style="font-family: 'Courier New',Courier,monospace; font-size: 140%;"> end loop **

<span style="color: #000080; font-family: Arial,Helvetica,sans-serif;">1) Modify any of your previous programs such that they have a graphical user interface.
Note: From this point on, all programs must be GUI compliant