Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Mouse Click Location
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sensfan




PostPosted: 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
Sponsor
sponsor
do_pete




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: Mon Dec 12, 2005 12:12 pm   Post subject: (No subject)

Can't edit posts here - I thought that would auto-link.

The tutorial is located here
http://www.compsci.ca/v2/viewtopic.php?t=6
Tony




PostPosted: Mon Dec 12, 2005 12:12 pm   Post subject: (No subject)

sensfan - do you intend on referencing the use of that code in your program?

Edit: note about autolinking
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
sensfan




PostPosted: Mon Dec 12, 2005 1:37 pm   Post subject: (No subject)

I will if you would like me to. No problems there.
Sponsor
Sponsor
Sponsor
sponsor
Albrecd




PostPosted: 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




PostPosted: 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 Wink 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: