Mouse Click Location
Author |
Message |
sensfan
|
Posted: Mon Dec 12, 2005 11:31 am Post subject: Mouse Click Location |
|
|
How can you tell Turing to recognize a mouse click within a certain boundary?
Like if you click within (x1,y1) and (x2,y2). it follows a certain command, as opposed to if you clicked within another space (box's around words, making a Menu)? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
do_pete

|
Posted: Mon Dec 12, 2005 11:37 am Post subject: (No subject) |
|
|
Try something like this:
code: | function CheckClick (x1, y1, x2, y2 : int) : boolean
var MouseX, MouseY, MouseButton : int
Mouse.Where (MouseX, MouseY, MouseButton)
if MouseButton not= 0 and MouseX > x1 and MouseX < x2 and MouseY > y1 and MouseY < y2 then
result true
else
result false
end if
end CheckClick
var Buttons : array 1 .. 4 of int
Buttons (1) := maxx div 2 - 50
Buttons (2) := 175
Buttons (3) := maxx div 2 + 50
Buttons (4) := 200
loop
if CheckClick (Buttons (1), Buttons (2), Buttons (3), Buttons (4)) then
Draw.Box (Buttons (1), Buttons (2), Buttons (3), Buttons (4), brightred)
else
Draw.Box (Buttons (1), Buttons (2), Buttons (3), Buttons (4), black)
end if
end loop
|
|
|
|
|
|
 |
sensfan
|
Posted: Mon Dec 12, 2005 11:49 am Post subject: (No subject) |
|
|
Cool, I can manipulate that to do what I need it to do. Thanks alot. |
|
|
|
|
 |
sensfan
|
Posted: Mon Dec 12, 2005 11:57 am Post subject: (No subject) |
|
|
Actually is there any possibility you could internally document that? I'm a little unfamiliar with a few commands that you used. I know what to do to use it where I need it but I'm just not sure about how it works. |
|
|
|
|
 |
codemage

|
Posted: Mon Dec 12, 2005 12:11 pm Post subject: (No subject) |
|
|
code: | var MouseX, MouseY, MouseButton : int
Mouse.Where (MouseX, MouseY, MouseButton) |
Mouse.Where finds out the X, Y location of the mouse, and the status of the button.
Check the
how to use a mouse in your turing programs
tutorial |
|
|
|
|
 |
codemage

|
|
|
|
 |
Tony

|
|
|
|
 |
sensfan
|
Posted: Mon Dec 12, 2005 1:37 pm Post subject: (No subject) |
|
|
I will if you would like me to. No problems there. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Albrecd
|
Posted: Mon Dec 12, 2005 2:00 pm Post subject: (No subject) |
|
|
Quote: I will if you would like me to.
Most people like it when you refrence the use of their code. |
|
|
|
|
 |
Tony

|
Posted: Mon Dec 12, 2005 2:42 pm Post subject: (No subject) |
|
|
You also don't get in trouble for taking other people's code.
We like it very much when CompSci.ca ends up acknowledged in assignments Remember that the more you promote the community, the more it grows, and in turn you get access to more resources and help in return.
Also people will be willing to help you out more, and comment code provided; knowing that you will actually learn from it rather than just submit as your own. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
|
|