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

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




PostPosted: Fri Nov 26, 2004 4:06 pm   Post subject: Mouse.Where help

i'm learning on how to make buttons change colours when the mouse goes over them and i have no idea how to do it except to use the predfined command Mouse.Where
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Nov 26, 2004 4:20 pm   Post subject: (No subject)

Mouse.Where sure is complicated eh? Not more complicated than the if statement! Those if statements, simple as they may seem, are more useful than more complicated functions like Mouse.Where. Without the if statements, you wouldn't be able to use Mouse.Where all that well.

So, back to the if statements we go!
You have a button, at drawn at (x1, y1, x2, y2). You also know the position of the mouse, at (x,y). So, use if statements.
code:

if x >= x1 and x <= x2 and y >= y1 and y <= y2 then
  the mouse is over the box
end if


Hurray for the if statements!
Tricia




PostPosted: Fri Nov 26, 2004 4:25 pm   Post subject: (No subject)

oh ic so i tried writing the code using that thanks and here's the code i wrote so this is wrong isn't it? coz it's not working
code:
var x, y : int := 0
drawfillbox (100, 200, 300, 400, 9)
if x >= 100 and x <= 300 and y >= 200 and y <= 400 then
    colour (8)wat do i have to put inside the if statement?
end if
DanShadow




PostPosted: Fri Nov 26, 2004 11:22 pm   Post subject: (No subject)

This is a simple layout for that. Although I warn you, seeing as your mouse is still over the box as it changes, it will continuously change colors until cursor moved outside box. But this answers your question...
code:

var x, y,box : int := 0
box:=1
if box=1 then
    drawfillbox (100, 200, 300, 400, 9)
elsif box=2 then
    drawfillbox(100,200,300,400,8)
end if
if x >= 100 and x <= 300 and y >= 200 and y <= 400 then
    if box=1 then
        box:=2
    elsif box=2 then
        box:=1
    end if
end if
Cervantes




PostPosted: Sat Nov 27, 2004 10:31 am   Post subject: (No subject)

Tricia wrote:
oh ic so i tried writing the code using that thanks and here's the code i wrote so this is wrong isn't it? coz it's not working
code:
var x, y : int := 0
drawfillbox (100, 200, 300, 400, 9)
if x >= 100 and x <= 300 and y >= 200 and y <= 400 then
    colour (8)wat do i have to put inside the if statement?
end if


using the colour(n : int) command only changes the colour of outputed text (using the put command). It does not change the colour of the box. To do that, you have to change the last parameter of the drawfillbox command.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: