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

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




PostPosted: Mon May 18, 2015 12:58 pm   Post subject: Mouse Help - Turing

I need help on the mouse functions in Turing.

Specifically, i want the user to click a region of the screen that will allow the program to perform a task when the region is being clicked on.

For example: lets say i had a box in the middle of the screen. When the user clicks anywhere in the box, the program will put "you have clicked the box"

How would I do this?
i.e., How would i make it so that when the user clicks a specified region, the program will perform a task.[/b]
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Mon May 18, 2015 1:17 pm   Post subject: RE:Mouse Help - Turing

Mouse.Where and conditionals using if statements.
Insectoid




PostPosted: Mon May 18, 2015 1:24 pm   Post subject: RE:Mouse Help - Turing

You just described a button. They're pretty easy to make. The Mouse.Where function will gather the mouse coordinates and button state at the time the function is called.

Mouse coordinates are just a point on the screen and the button is just a rectangle (or circle, or any shape, but a rectangle for now). You need your code to determine if the mouse is inside the rectangle or not when the button is pressed.

Remember that a rectangle in Turing has two points, (x1, y1), the bottom left, and (x2, y2), the top right. Draw a rectangle on a piece of paper to represent the button and a dot inside it to represent the mouse. Label (x1, y1) and (x2, y2) on the rectangle as well as (x,y) at the point.

Look at your coordinates and try to figure out under what conditions the point is inside the rectangle and which it is not. You'll be using your greater than (>) and less than (<) signs.
akenno




PostPosted: Mon May 18, 2015 1:38 pm   Post subject: Re: RE:Mouse Help - Turing

Insectoid @ Mon May 18, 2015 1:24 pm wrote:
You just described a button. They're pretty easy to make. The Mouse.Where function will gather the mouse coordinates and button state at the time the function is called.

Mouse coordinates are just a point on the screen and the button is just a rectangle (or circle, or any shape, but a rectangle for now). You need your code to determine if the mouse is inside the rectangle or not when the button is pressed.

Remember that a rectangle in Turing has two points, (x1, y1), the bottom left, and (x2, y2), the top right. Draw a rectangle on a piece of paper to represent the button and a dot inside it to represent the mouse. Label (x1, y1) and (x2, y2) on the rectangle as well as (x,y) at the point.

Look at your coordinates and try to figure out under what conditions the point is inside the rectangle and which it is not. You'll be using your greater than (>) and less than (<) signs.


If it wouldn't be too much trouble, would you show me how to actually code it? I understand the concept of what you said, but im having trouble visualizing it in code.
Insectoid




PostPosted: Mon May 18, 2015 1:46 pm   Post subject: RE:Mouse Help - Turing

I'm afraid that would be too much trouble. If you understand the concept you should have no trouble writing the code. Do you understand how the Mouse.Where command works? Zren has provided a link to the documentation if you do not. Beyond that, you only need to understand loops, if statements, the 'and' operator and the > & < operators. If you are having trouble with any of those I'd be happy to help but you'll have to write the actual code yourself.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: