Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Menu
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
starlight




PostPosted: Wed May 11, 2005 4:19 pm   Post subject: Menu

I search over the website about the function of the mouse in turing. And i Found few which have the same problem as I do. I read over the solution but I don't really understand it.

My question is
How do you make a menu that allows the user to imput their selction through a bottom (mouse-clicking )? Then the new page will be outputed. The new page will also allow the user to go back to the menu using the mouse. I know it requires mouse where, and some if statement but i just can't put them together. Help is appreciated. I treid the GUI function. But it is sorta complicated so I 'll stick with the mousewhere function.

Our teacher haven't teach us about the mouse function yet. But I want to surprise her. Razz
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu May 12, 2005 3:27 pm   Post subject: (No subject)

The most basic thing you'll need to understand is how to determine if the mouse is over top of the button. We know the coordinates of the box (we must, since we are drawing the box to the screen!) and the coordinates of the mouse (via Mouse.Where). To check if the mouse is inside the box, we can do something like this:
code:

%(x1,y1) represents the bottom left corner of the box
%(x2, y2) represents the top right corner of the box
if mouseX >= x1 and mouseX <= x2 and mouseY >= y1 and mouseY <= y2 then
  put "Mouse is inside the box"
else
  put "Mouse is outside the box"
end if


If you don't know how to use Mouse.Where, check the help file, or check the turing tutorials section. With those two sources, it should be easy to understand.
starlight




PostPosted: Thu May 12, 2005 6:30 pm   Post subject: (No subject)

Hey I think I got it. Laughing Thanks.
code:


var x1, y1, x2, y2, x, y,x9, button, x3, x4, mouseX, mouseY : int
x1 := 10%x-cordinate for left side of the box 1
y1 := 30%y-cordinate for left side of the box 1&2
x2 := 83%x-cordinate for right side of the box 1
y2 := 60%y-cordinate for right side of the box 1&2
x3 := 100%x-cordinate for left side of the box 2
x4 := 180%x-cordinate for right side of the box 2
x9:=1


    loop

        drawbox (x1, y1, x2, y2, black)
        locate(23,14)
        put" Button 2"..
        drawbox (x3, y1, x4, y2, black)
        locate(23,3)
        put"Button 1"..
        Mouse.Where (x, y, button)
       
        if button not= 0 and x >= x1 and x <= x2 and y >= y1 and y <= y2
        then
       
    delay(100)
    cls
    locate(x9,1)
    put "star"

elsif button not= 0 and x >= x3 and x <= x4 and y >= y1 and y <= y2
then
       
    delay(100)
    cls
    locate(x9,1)
    put "moon"

        end if
    end loop

   
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: