Computer Science Canada

Clicking a button with the mouse?

Author:  poomanchunk [ Thu Apr 29, 2004 7:00 pm ]
Post subject:  Clicking a button with the mouse?

Hey, I'm new here. I'm also just in my first year of computer science. I bet you may think I'm dumb, but remember, im a first yearer.
But anyways how do you actually make something where you can click a button or something and it'll move onto the next part. I was playing some trivia games in my class and someone I don't know how a button where you could click it. I never got a chance to ask him how he did it.
Plz could someone tell me how to do this, as I know many people will know how.

Author:  Cervantes [ Thu Apr 29, 2004 7:05 pm ]
Post subject: 

use mousewhere.

code:

var x, y, btn : int

drawfillbox (100, 100, 150, 150, green)
loop

mousewhere (x,y,btn)

if x >= 100 and x <= 150 and y >= 100 and y <= 150 and btn = 1 then
   buttonclicked := true
end if

end loop


buttonclicked, in this case, is just a boolean variable. you can do whatever you want inside the if statement.

understand?

oh, the other way is GUI, but that is the evil route. walk in the light. Wink

Author:  poomanchunk [ Thu Apr 29, 2004 7:21 pm ]
Post subject: 

Ok thx that worked, but how do you continue on with the program. Like when I click the button it just goes white and nothing appears after it.

Author:  Tony [ Thu Apr 29, 2004 7:24 pm ]
Post subject: 

Cervantes wrote:
you can do whatever you want inside the if statement.


it might be best to just call a procedure once you determine that the button was clicked

Author:  poomanchunk [ Thu Apr 29, 2004 7:27 pm ]
Post subject: 

Ohh, nvm i get how to do it.
I didn't really know what u meant by the "do whatever in the if statement" but now i know thx!!

Author:  Flashkicks [ Fri Apr 30, 2004 5:32 am ]
Post subject: 

And GUI aint Evil---Its just hard to understand cuz its so hidden in the dark Laughing Twisted Evil

Author:  Tony [ Fri Apr 30, 2004 6:09 am ]
Post subject: 

Flashkicks wrote:
Its just hard to understand

its not hard to understand, it's just poorly writen and basically a shitty module


: