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

Username:   Password: 
 RegisterRegister   
 Mouse Commands: Mouse.ButtonWait and Mouse.Where
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bwong




PostPosted: Sat Jun 04, 2011 8:32 pm   Post subject: Mouse Commands: Mouse.ButtonWait and Mouse.Where

What is it you are trying to achieve?
I am making a menu, where when users scroll over an object, the name attributed to the object will appear, and when the user scrolls away from the object, it will go back to black. at the same time, I want to make it so that when the user clicks on it, the object will link to somewhere else.


What is the problem you are having?
I am able to have both of these functions work independently, but when I try to implement them together, it does not work.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
All variables have been declared beforehand.
Turing:


%%%MAIN MENU%%%
%This creates the on-mouse-over effect
loop
Mouse.Where (mousex, mousey, mousedown)
if mousex >= 584 and mousex <= 690 and mousey >= 100 and mousey <= 220
    then Font.Draw ("Exit", 690, 100, font1, white)
elsif mousex >= 170 and mousex <= 259 and mousey >= 265 and mousey <= 371
    then Font.Draw ("Test", 125, 265, font1, white)
elsif mousex >= 364 and mousex <= 443 and mousey >= 289 and mousey <= 357
    then Font.Draw ("Information", 545, 303, font1, white)
elsif mousex >= 256 and mousex <= 325 and mousey >= 399 and mousey <= 467
    then Font.Draw ("Results", 160, 438, font1, white)
elsif mousex >= 066 and mousex <= 145 and mousey >= 357 and mousey <= 445
    then Font.Draw ("Animation", 015, 350, font1, white)
else
    erasetext
end if
end loop
%This enables the button down option
Mouse.ButtonWait ("down", mousex, mousey, mousesel, mousedown
if mousex >= 584 and mousex <= 690 and mousey >= 100 and mousey <= 220
    then cls
elsif mousex >= 170 and mousex <= 259 and mousey >= 265 and mousey <= 371
    then cls
elsif mousex >= 364 and mousex <= 443 and mousey >= 289 and mousey <= 357
    then cls
elsif mousex >= 256 and mousex <= 325 and mousey >= 399 and mousey <= 467
    then cls
elsif mousex >= 066 and mousex <= 145 and mousey >= 357 and mousey <= 445
    then cls
end if



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Badsniper




PostPosted: Sat Jun 04, 2011 9:56 pm   Post subject: Re: Mouse Commands: Mouse.ButtonWait and Mouse.Where

Look at the comments I put in.

Turing:

loop

    Mouse.Where (mousex, mousey, mousedown)
    if mousex >= 584 and mousex <= 690 and mousey >= 100 and mousey <= 220
            then
        Font.Draw ("Exit", 690, 100, font1, white)
        %Put a boolean variable in here! set it to true!
    elsif mousex >= 170 and mousex <= 259 and mousey >= 265 and mousey <= 371
            then
        Font.Draw ("Test", 125, 265, font1, white)
        %Put a boolean variable in here! set it to true!
    elsif mousex >= 364 and mousex <= 443 and mousey >= 289 and mousey <= 357
            then
        Font.Draw ("Information", 545, 303, font1, white)
        %Put a boolean variable in here! set it to true!
    elsif mousex >= 256 and mousex <= 325 and mousey >= 399 and mousey <= 467
            then
        Font.Draw ("Results", 160, 438, font1, white)
        %Put a boolean variable in here! set it to true!
    elsif mousex >= 066 and mousex <= 145 and mousey >= 357 and mousey <= 445
            then
        Font.Draw ("Animation", 015, 350, font1, white)
    else
        erasetext
    end if

    %If the boolean variable is true, wait for a click!
    Mouse.ButtonWait ("down", mousex, mousey, mousesel, mousedown)
    if mousex >= 584 and mousex <= 690 and mousey >= 100 and mousey <= 220
            then
        cls
    elsif mousex >= 170 and mousex <= 259 and mousey >= 265 and mousey <= 371
            then
        cls
    elsif mousex >= 364 and mousex <= 443 and mousey >= 289 and mousey <= 357
            then
        cls
    elsif mousex >= 256 and mousex <= 325 and mousey >= 399 and mousey <= 467
            then
        cls
    elsif mousex >= 066 and mousex <= 145 and mousey >= 357 and mousey <= 445
            then
        cls
    end if

    %Set Boolean variable back to false
   
end loop
Raknarg




PostPosted: Sat Jun 04, 2011 10:41 pm   Post subject: RE:Mouse Commands: Mouse.ButtonWait and Mouse.Where

The issue is that you are using cls. This clears the entire screen, not just the box. Instead, you should say something like draw a box over the selected area. Just to make you life easier, if I were you, I would scrap the second set of ifs. Instead, use that drawfillbox method I talked about and put it beforehand. That way, it'll always draw the black boxes in, but it'll write over it if the mouse is over the box.
bwong




PostPosted: Sun Jun 05, 2011 8:02 pm   Post subject: Re: RE:Mouse Commands: Mouse.ButtonWait and Mouse.Where

Raknarg @ Sat Jun 04, 2011 10:41 pm wrote:
The issue is that you are using cls. This clears the entire screen, not just the box. Instead, you should say something like draw a box over the selected area. Just to make you life easier, if I were you, I would scrap the second set of ifs. Instead, use that drawfillbox method I talked about and put it beforehand. That way, it'll always draw the black boxes in, but it'll write over it if the mouse is over the box.

My bad. The cls was only used to indicate that the click function worked (independently) because I haven't finished everything else yet.

Oh, and at BadSniper, how would, or what should I do to implement such boolean variables?
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  [ 4 Posts ]
Jump to:   


Style:  
Search: