1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
psychojs/docs/module-core.Mouse.html
Alain Pitiot 60cfc55627 _
2021-05-31 08:32:35 +02:00

1748 lines
24 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Mouse</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Mouse</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-core.html">core</a>.</span>Mouse<span class="signature">(options)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Mouse"><span class="type-signature"></span>new Mouse<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This manager handles the interactions between the experiment's stimuli and the mouse.</p>
<p>Note: the unit of Mouse is that of its associated Window.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the name used when logging messages from this stimulus</td>
</tr>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type">Window</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the associated Window</td>
</tr>
<tr>
<td class="name"><code>autoLog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
true
</td>
<td class="description last">whether or not to log</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line16">line 16</a>
</li></ul></dd>
<dt class="tag-todo">To Do:</dt>
<dd class="tag-todo">
<ul>
<li>visible is not handled at the moment (mouse is always visible)</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>PsychObject</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="clickReset"><span class="type-signature"></span>clickReset<span class="signature">(buttons<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Reset the clocks associated to the given mouse buttons.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>buttons</code></td>
<td class="type">
<span class="param-type">Array.number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
[0,1,2]
</td>
<td class="description last">the buttons to reset (0: left, 1: center, 2: right)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line341">line 341</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getPos"><span class="type-signature"></span>getPos<span class="signature">()</span><span class="type-signature"> &rarr; {Array.number}</span></h4>
<div class="description">
Get the current position of the mouse in mouse/Window units.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line57">line 57</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the position of the mouse in mouse/Window units
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.number</span>
</dd>
</dl>
<h4 class="name" id="getPressed"><span class="type-signature"></span>getPressed<span class="signature">(getTime<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.number|Array.&lt;Array.number>}</span></h4>
<div class="description">
Get the status of each button (pressed or released) and, optionally, the time elapsed between the last call to <a href="module-core.Mouse.html#clickReset">clickReset</a> and the pressing or releasing of the buttons.
<p>Note: clickReset is typically called at stimulus onset. When the participant presses a button, the time elapsed since the clickReset is stored internally and can be accessed any time afterwards with getPressed.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>getTime</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to also return timestamps</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line131">line 131</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
either an array of size 3 with the status (1 for pressed, 0 for released) of each mouse button [left, center, right], or a tuple with that array and another array of size 3 with the timestamps.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.number</span>
|
<span class="param-type">Array.&lt;Array.number></span>
</dd>
</dl>
<h4 class="name" id="getRel"><span class="type-signature"></span>getRel<span class="signature">()</span><span class="type-signature"> &rarr; {Array.number}</span></h4>
<div class="description">
Get the position of the mouse relative to that at the last call to getRel
or getPos, in mouse/Window units.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line82">line 82</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the relation position of the mouse in mouse/Window units.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.number</span>
</dd>
</dl>
<h4 class="name" id="getWheelRel"><span class="type-signature"></span>getWheelRel<span class="signature">()</span><span class="type-signature"> &rarr; {Array.number}</span></h4>
<div class="description">
Get the travel of the mouse scroll wheel since the last call to getWheelRel.
<p>Note: Even though this method returns a [x, y] array, for most wheels/systems y is the only
value that varies.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line107">line 107</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the mouse scroll wheel travel
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.number</span>
</dd>
</dl>
<h4 class="name" id="isPressedIn"><span class="type-signature"></span>isPressedIn<span class="signature">(shape, buttons<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<div class="description">
Helper method for checking whether a stimulus has had any button presses within bounds.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>shape</code></td>
<td class="type">
<span class="param-type">object</span>
|
<span class="param-type"><a href="module-visual.VisualStim.html">module:visual.VisualStim</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">A type of visual stimulus or object having a `contains()` method.</td>
</tr>
<tr>
<td class="name"><code>buttons</code></td>
<td class="type">
<span class="param-type">object</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">The target button index potentially tucked inside an object.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>shape</code></td>
<td class="type">
<span class="param-type">object</span>
|
<span class="param-type"><a href="module-visual.VisualStim.html">module:visual.VisualStim</a></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>buttons</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line157">line 157</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Whether button pressed is contained within stimulus.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="mouseMoved"><span class="type-signature"></span>mouseMoved<span class="signature">(distance<span class="signature-attributes">opt</span>, reset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<div class="description">
Determine whether the mouse has moved beyond a certain distance.
<p><b>distance</b>
<ul>
<li>mouseMoved() or mouseMoved(undefined, false): determine whether the mouse has moved at all since the last
call to <a href="module-core.Mouse.html#getPos">getPos</a></li>
<li>mouseMoved(distance: number, false): determine whether the mouse has travelled further than distance, in terms of line of sight</li>
<li>mouseMoved(distance: [number,number], false): determine whether the mouse has travelled horizontally or vertically further then the given horizontal and vertical distances</li>
</ul></p>
<p><b>reset</b>
<ul>
<li>mouseMoved(distance, true): reset the mouse move clock, return false</li>
<li>mouseMoved(distance, 'here'): return false</li>
<li>mouseMoved(distance, [x: number, y: number]: artifically set the previous mouse position to the given coordinates and determine whether the mouse moved further than the given distance</li>
</ul></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>distance</code></td>
<td class="type">
<span class="param-type">undefined</span>
|
<span class="param-type">number</span>
|
<span class="param-type">Array.number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last">the distance to which the mouse movement is compared (see above for a full description)</td>
</tr>
<tr>
<td class="name"><code>reset</code></td>
<td class="type">
<span class="param-type">boolean</span>
|
<span class="param-type">String</span>
|
<span class="param-type">Array.number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">see above for a full description</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line215">line 215</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
see above for a full description
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="mouseMoveTime"><span class="type-signature"></span>mouseMoveTime<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
<div class="description">
Get the amount of time elapsed since the last mouse movement.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_Mouse.js.html">core/Mouse.js</a>, <a href="core_Mouse.js.html#line327">line 327</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the time elapsed since the last mouse movement
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="module-core.BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="module-core.EventManager.html">EventManager</a></li><li><a href="module-core.GUI.html">GUI</a></li><li><a href="module-core.Keyboard.html">Keyboard</a></li><li><a href="module-core.KeyPress.html">KeyPress</a></li><li><a href="module-core.Logger.html">Logger</a></li><li><a href="module-core.MinimalStim.html">MinimalStim</a></li><li><a href="module-core.Mouse.html">Mouse</a></li><li><a href="module-core.PsychoJS.html">PsychoJS</a></li><li><a href="module-core.ServerManager.html">ServerManager</a></li><li><a href="module-core.Window.html">Window</a></li><li><a href="module-data.ExperimentHandler.html">ExperimentHandler</a></li><li><a href="module-data.Shelf.html">Shelf</a></li><li><a href="module-data.TrialHandler.html">TrialHandler</a></li><li><a href="module-sound.AudioClip.html">AudioClip</a></li><li><a href="module-sound.Microphone.html">Microphone</a></li><li><a href="module-sound.Sound.html">Sound</a></li><li><a href="module-sound.TonePlayer.html">TonePlayer</a></li><li><a href="module-sound.TrackPlayer.html">TrackPlayer</a></li><li><a href="module-sound.Transcriber.html">Transcriber</a></li><li><a href="module-sound.Transcript.html">Transcript</a></li><li><a href="module-util.Clock.html">Clock</a></li><li><a href="module-util.Color.html">Color</a></li><li><a href="module-util.CountdownTimer.html">CountdownTimer</a></li><li><a href="module-util.EventEmitter.html">EventEmitter</a></li><li><a href="module-util.MixinBuilder.html">MixinBuilder</a></li><li><a href="module-util.MonotonicClock.html">MonotonicClock</a></li><li><a href="module-util.PsychObject.html">PsychObject</a></li><li><a href="module-util.Scheduler.html">Scheduler</a></li><li><a href="module-visual.Form.html">Form</a></li><li><a href="module-visual.ImageStim.html">ImageStim</a></li><li><a href="module-visual.MovieStim.html">MovieStim</a></li><li><a href="module-visual.Polygon.html">Polygon</a></li><li><a href="module-visual.Rect.html">Rect</a></li><li><a href="module-visual.ShapeStim.html">ShapeStim</a></li><li><a href="module-visual.Slider.html">Slider</a></li><li><a href="module-visual.TextBox.html">TextBox</a></li><li><a href="module-visual.TextStim.html">TextStim</a></li><li><a href="module-visual.VisualStim.html">VisualStim</a></li><li><a href="TextInput.html">TextInput</a></li></ul><h3>Interfaces</h3><ul><li><a href="module-sound.SoundPlayer.html">SoundPlayer</a></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a></li><li><a href="module-util.ColorMixin.html">ColorMixin</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri May 28 2021 10:49:17 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>