Computer Science Canada

mouse function

Author:  mercuryy [ Sat May 07, 2005 9:06 pm ]
Post subject:  mouse function

How do you use the mouse-clicking method to proceed from the original screen to the next screen of turing? like a "slide show". like u click on a word which takes you to the next page? i check the turing reference. It gives me something like the Mouse.ButtonChoose but i don't really get it. Can anyone give me a practical example?

Author:  Cervantes [ Sun May 08, 2005 7:44 am ]
Post subject: 

For this, you'd probably want to use Mouse.ButtonWait. It's kind of like getch, only for the mouse. The simplest way to link the pictures is to assign a number to each picutre. Each time you click, the number increases by one. The picture associated with that number is always on the screen. This isn't the best way to do it, but it's the simplest (and probably just as good for your purposes) Smile

Author:  mercuryy [ Sun May 08, 2005 9:56 am ]
Post subject: 

Humm. I still don't really get it. i look up the mouse.bottomwait function in the turing reference. and it doesn't really tell me much. Can anyone give me an simple example of how it should be done and i learn from it?

p.s may i suggess someone do a toturial on mouse function? i did a search but i don't think I found anything.

Author:  Token [ Sun May 08, 2005 9:36 pm ]
Post subject: 

here what you would do is add all of your pics into an array. the code is pretty simple, and self explanitory, if you have a question just ask


code:

var x, y, b, next, pic : int := 0

loop
    loop
        mousewhere (x, y, b)
        exit when b = 1

    end loop
    next := 1
    pic += 1
    loop
        mousewhere (x, y, b)
        exit when b = 0


    end loop
    next := 0

%%%%draw pic here
%%somthin like     Pic.Draw (picture (pic), 0, 0, 0)

end loop

Author:  mercuryy [ Wed May 11, 2005 4:11 pm ]
Post subject: 

I tried this
code:

var x, y, b, next, TR : int := 0

loop
    loop
        mousewhere (x, y, b)
        exit when b = 1

    end loop
    next := 1
    TR += 1
    loop
        mousewhere (x, y, b)
        exit when b = 0


    end loop
    next := 0

Pic.Draw (TR, 0, 0, picCopy)
end loop

but for some reason it doesn't work out.
It output an error massage "1 is not a legal identifier"

Author:  Token [ Wed May 11, 2005 4:26 pm ]
Post subject: 

Your problem was that you were using a number in stead of an identifier, so what you had to do was change it so that when you import the pictures you put them into an array, name them pic1, pic2 pic3 ...

code:
var x, y, b, next, TR : int := 0
var marks : array 1 .. 10 of int


for i : 1 .. 10
    pic (i) := Pic.FileNew ("pic", intstr (i) + ".jpg")
end for

loop
    loop
        mousewhere (x, y, b)
        exit when b = 1

    end loop
    next := 1
    TR += 1
    loop
        mousewhere (x, y, b)
        exit when b = 0


    end loop
    next := 0

    Pic.Draw (pic (TR), 0, 0, picCopy)
end loop


: