Computer Science Canada

Mouse commands with a procedure

Author:  HaVoC [ Thu Dec 18, 2003 2:12 pm ]
Post subject:  Mouse commands with a procedure

Is it possible to call a procedure and have it able to be used with a mouse. Like
code:

proc button
drawbox (x,y,x,y,black)
end button

button


Is it possible to make that clickable and give an output. And say I can add two button outputs together.
button = 1
buttonw = 2
result = 1 and 2(not 1+2)
result= 12 not 3

Author:  Dan [ Thu Dec 18, 2003 5:59 pm ]
Post subject: 

you can use mousewhere for this:

mousewhere (var x, y, button : int)

it puts the x an y values of the mouse in to the 1st 2 varibles you put in and the condition of the button in the 3rd.

Ex form the turing doc:

code:

var x, y, button : int
loop
    mousewhere (x, y, button)
    locate (1, 1)
    if button = 0 then
        put x : 4, "  ", y : 4, "  button up"
    else
        put x : 4, "  ", y : 4, "  button down"
    end if
end loop


now to tell if they clicked on your botton you whould uses consion dection with the x and y values of the mouse withch only activates when the mouse botton is down.

there is more info on collsion dection in the turing tuttorial section.


: