Debian Codegraph @

docs/manual/Demo_window_3__Getting_click_locations.html

raw
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Demo window 3. Getting click locations</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 Demo window 3. Getting click locations
13 </b></font></table></table>
14 <p>You can use the functions <a href="_demoX_.html"><b><code><font size=+1>demoX</font></code></b></a> and <a href="_demoY_.html"><b><code><font size=+1>demoY</font></code></b></a> to see where the user has clicked. These functions respond in world coordinates. To see whether the user has clicked in the sound that occupies the upper half of the screen in the above example, you do for instance</p>
15 <code> while <a href="_demoWaitForInput_.html">demoWaitForInput</a> ()<br></code>
16 <code> if <a href="_demoClicked_.html">demoClicked</a> ()<br></code>
17 <code> <a href="_demo_.html">demo</a> Select outer viewport: 0, 100, 50, 100<br></code>
18 <code> <a href="_demo_.html">demo</a> Axes: 0, 3, -1, 1<br></code>
19 <code> if <b><a href="_demoX_.html">demoX</a></b> () &gt;= 0 and <b><a href="_demoX_.html">demoX</a></b> () &lt; 3 and <b><a href="_demoY_.html">demoY</a></b> () &gt;= -1 and <b><a href="_demoY_.html">demoY</a></b> () &lt; 1<br></code>
20 <p>The last line can be shortened to:</p>
21 <code> if <b><a href="_demoClickedIn_.html">demoClickedIn</a></b> (0, 3, -1, 1)<br></code>
22 <p>Another example of when you want to know the click location is when you test for a click on a button that you drew on the screen:</p>
23 <code> <b><a href="_demo_.html">demo</a></b> Paint rounded rectangle: “pink”, 30, 70, 16, 24<br></code>
24 <code> <b><a href="_demo_.html">demo</a></b> Text: 50, “centre”, 20, “half”, “Analyse”<br></code>
25 <code> while <b><a href="_demoWaitForInput_.html">demoWaitForInput</a></b> ()<br></code>
26 <code> goto ANALYSE <b><a href="_demoClickedIn_.html">demoClickedIn</a></b> (30, 70, 16, 24)<br></code>
27 <h3>Links to this page</h3>
28 <ul>
29 <li><a href="Demo_window.html">Demo window</a>
30 </ul>
31 <hr>
32 <address>
33 <p>© Paul Boersma 2009-2023</p>
34 </address>
35 </body>
36 </html>