Computer Science Canada

mouse clicking

Author:  avsrule192002 [ Sat Jan 22, 2005 2:08 pm ]
Post subject:  mouse clicking

Do you know the code for clicking my mouse on a START button on the output screen?

Author:  Cervantes [ Sat Jan 22, 2005 2:48 pm ]
Post subject: 

Check out Mouse.Where. Search the tutorials section for it, for use the Turing Help File.
Use that, in combination with if statements, to check if you've clicked on a button.
Or, you could use Turing's built-in GUI, which sucks. The choice is yours.
-Cervantes

Author:  MihaiG [ Sat Jan 22, 2005 3:18 pm ]
Post subject: 

try this

code:

setscreen ("graphics:max;max")
View.Set ("offscreenonly")
Mouse.ButtonChoose ("multibutton")

var x,y,b : int % x is mouses x position y is mouses y position and b is the button
loop
cls
mousewhere (x,y,b)
put "mouse position is (",x," , ",y,")"
put "The button pressed is ",b,""
View.Update

end loop

that should give you an idea of how the mouse works have fun Smile

Author:  basketball4ever [ Sat Jan 22, 2005 3:22 pm ]
Post subject: 

code:
var x, y, button : int
loop
    drawfillbox (100, 100, 200, 200, 7)
    mousewhere (x, y, button)
    if button = 1 then
        if (x >= 100 and x <= 200) and (y >= 100 and y <= 200) then
            put "YAY"
            exit
        else
            locate(3,1)
            put"Try again"
        end if
    end if
end loop


this might help

Author:  Bacchus [ Sat Jan 22, 2005 4:18 pm ]
Post subject: 

Cervantes wrote:

Or, you could use Turing's built-in GUI, which sucks.

why does the GUI sucks so much? i used it before and it was pretty good. worked well for me cause im not in the least bit creative enouph to make really good non-gui buttons

Author:  basketball4ever [ Sat Jan 22, 2005 5:21 pm ]
Post subject: 

Bacchus wrote:
Cervantes wrote:

Or, you could use Turing's built-in GUI, which sucks.

why does the GUI sucks so much? i used it before and it was pretty good. worked well for me cause im not in the least bit creative enouph to make really good non-gui buttons


I think the problem with GUI.Buttons are that they dont look nice : P very very ugly ... if u want a special designed button dont use gui.... as well... to use GUI.Buttons... you also need getwidgeteventid.... which u also need remember... which is really really nasty...
however... by making your own button... a simple if statement can be used

Author:  cool dude [ Sat Jan 22, 2005 5:36 pm ]
Post subject: 

this should help

code:

var font : int
var click : boolean
var button:int
var x,y : int
font := Font.New ("arial:20")
drawfillbox (100,300,200,350,4)
Font.Draw ("start",110,310,font,7)

click:=false
loop
mousewhere (x,y,button)
if button=1 then
if x >=100 and x<= 200 and y>=300 and y<=350 then
click:=true
put "put watever u wanna do next"
exit
else
put "put watever u wanna do if they clicked somewhere else"
exit
end if
end if
end loop

Author:  ste_louis26 [ Tue Jan 25, 2005 12:58 pm ]
Post subject: 

I think theres a certain way to place the GUI and thats why it doesn't work well for me. You could also draw a box and use mouse.where to track if they click in it
here's something that may help you click on your button

code:
var finished :boolean  := false
var rangex, rangey, button : int
         locate (3,1)
                put "Click on this screen."
  procedure display
               drawfillbox(0,100,200, 200, green)
        mousewhere(rangex,rangey,button)
    locate(10,1)
                        put rangex, " ",rangey

        if button = 1 then             
           if (rangex >=0 and rangex <=200) and (rangey >=100 and rangey <= 200) then
                        cls
                        put finished
                        finished := true       
                      end if
end if
                      end display
 
loop                   
 display
        exit when finished     
end loop
     
[/code]


: