
-----------------------------------
akenno
Mon May 18, 2015 12:58 pm

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]

-----------------------------------
Zren
Mon May 18, 2015 1:17 pm

RE:Mouse Help - Turing
-----------------------------------
[tdoc]Mouse.Where[/tdoc] and conditionals using if statements.

-----------------------------------
Insectoid
Mon May 18, 2015 1:24 pm

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 () and less than ( & < 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.
