/
MouseEvent.cljs
375 lines (264 loc) · 11.1 KB
/
MouseEvent.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
(ns web.MouseEvent
"The MouseEvent interface represents events that occur due to
user interacting with a pointing device (such as a mouse). Common
using this interface include click, dblclick, mouseup, mousedown."
(:refer-clojure :exclude []))
(def constructor
"Constructor.
The MouseEvent() constructor creates a new `web.MouseEvent`.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent`"
js/MouseEvent)
(defn get-modifier-state
"Method.
The MouseEvent.getModifierState() method returns the current
of the specified modifier key: true if the modifier is active
the modifier key is pressed or locked), otherwise, false.
`var active = event.getModifierState(keyArg);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/getModifierState`"
[this key-arg]
(-> this (.getModifierState key-arg)))
(defn init-mouse-event
"Method.
The MouseEvent.initMouseEvent() method initializes the value
a mouse event once it's been created (normally using the `Document.createEvent()`
`event.initMouseEvent(type, canBubble, cancelable, view,
detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey,
button, relatedTarget);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent`"
[this & args]
(apply (-> this .-initMouseEvent) (concat [this] args)))
(defn alt-key
"Property.
The MouseEvent.altKey read-only property is a `js.Boolean` that
whether the alt key was pressed or not when a given mouse event
`var altKeyPressed = instanceOfMouseEvent.altKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey`"
[this]
(-> this (.altKey)))
(defn button
"Property.
The MouseEvent.button read-only property indicates which button
pressed on the mouse to trigger the event.
`var buttonPressed = instanceOfMouseEvent.button`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button`"
[this]
(-> this (.button)))
(defn buttons
"Property.
The MouseEvent.buttons read-only property indicates which buttons
pressed on the mouse (or other input device) when a mouse event
triggered.
`var buttonsPressed = instanceOfMouseEvent.buttons`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons`"
[this]
(-> this (.buttons)))
(defn client-x
"Property.
The clientX read-only property of the `web.MouseEvent` interface
the horizontal coordinate within the application's client area
which the event occurred (as opposed to the coordinate within
page).
`var x = instanceOfMouseEvent.clientX`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX`"
[this]
(-> this (.clientX)))
(defn client-y
"Property.
The clientY read-only property of the `web.MouseEvent` interface
the vertical coordinate within the application's client area
which the event occurred (as opposed to the coordinate within
page).
`var y = instanceOfMouseEvent.clientY`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY`"
[this]
(-> this (.clientY)))
(defn ctrl-key
"Property.
The MouseEvent.ctrlKey read-only property is a `js.Boolean` that
whether the ctrl key was pressed or not when a given mouse event
`var ctrlKeyPressed = instanceOfMouseEvent.ctrlKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/ctrlKey`"
[this]
(-> this (.ctrlKey)))
(defn meta-key
"Property.
The MouseEvent.metaKey read-only property is a `js.Boolean` that
whether the meta key was pressed or not when a given mouse event
`var metaKeyPressed = instanceOfMouseEvent.metaKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/metaKey`"
[this]
(-> this (.metaKey)))
(defn movement-x
"Property.
The movementX read-only property of the `web.MouseEvent` interface
the difference in the X coordinate of the mouse pointer between
given event and the previous mousemove event. In other words,
value of the property is computed like this: currentEvent.movementX
currentEvent.screenX - previousEvent.screenX.
`var xShift = instanceOfMouseEvent.movementX;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX`"
[this]
(-> this (.movementX)))
(defn movement-y
"Property.
The movementY read-only property of the `web.MouseEvent` interface
the difference in the Y coordinate of the mouse pointer between
given event and the previous mousemove event. In other words,
value of the property is computed like this: currentEvent.movementY
currentEvent.screenY - previousEvent.screenY.
`var yShift = instanceOfMouseEvent.movementY;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementY`"
[this]
(-> this (.movementY)))
(defn moz-input-source
"Property.
The MouseEvent.mozInputSource read-only property on `web.MouseEvent`
information indicating the type of device that generated the
This lets you, for example, determine whether a mouse event was
by an actual mouse or by a touch event (which might affect the
of accuracy with which you interpret the coordinates associated
the event).
`var source = instanceOfMouseEvent.mozInputSource;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/mozInputSource`"
[this]
(-> this (.mozInputSource)))
(defn offset-x
"Property.
The offsetX read-only property of the `web.MouseEvent` interface
the offset in the X coordinate of the mouse pointer between that
and the padding edge of the target node.
`var xOffset = instanceOfMouseEvent.offsetX;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX`"
[this]
(-> this (.offsetX)))
(defn offset-y
"Property.
The offsetY read-only property of the `web.MouseEvent` interface
the offset in the Y coordinate of the mouse pointer between that
and the padding edge of the target node.
`var yOffset = instanceOfMouseEvent.offsetY;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetY`"
[this]
(-> this (.offsetY)))
(defn page-x
"Property.
The pageX read-only property of the `web.MouseEvent` interface
the X (horizontal) coordinate (in pixels) at which the mouse
clicked, relative to the left edge of the entire document.
`var pageX = MouseEvent.pageX;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageX`"
[this]
(-> this (.pageX)))
(defn page-y
"Property.
The pageY read-only property of the `web.MouseEvent` interface
the Y (vertical) coordinate in pixels of the event relative to
whole document. This property takes into account any vertical
of the page.
`var pos = event.pageY;
Originally, this property was defined as a long integer. The CSSOM View Module redefined it as a double float. See the Browser compatibility section for details.`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageY`"
[this]
(-> this (.pageY)))
(defn region
"Property.
The MouseEvent.region read-only property returns the id of the
hit region affected by the event. If no hit region is affected,
is returned.
`var hitRegion = instanceOfMouseEvent.region`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/region`"
[this]
(-> this (.region)))
(defn related-target
"Property.
The MouseEvent.relatedTarget read-only property is the secondary
for the mouse event, if there is one. That is:
`var target = instanceOfMouseEvent.relatedTarget`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/relatedTarget`"
[this]
(-> this (.relatedTarget)))
(defn screen-x
"Property.
The screenX read-only property of the `web.MouseEvent` interface
the horizontal coordinate (offset) of the mouse pointer in global
coordinates.
`var x = instanceOfMouseEvent.screenX`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenX`"
[this]
(-> this (.screenX)))
(defn screen-y
"Property.
The screenY read-only property of the `web.MouseEvent` interface
the vertical coordinate (offset) of the mouse pointer in global
coordinates.
`var y = instanceOfMouseEvent.screenY`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY`"
[this]
(-> this (.screenY)))
(defn shift-key
"Property.
The MouseEvent.shiftKey read-only property is a `js.Boolean`
indicates whether the shift key was pressed or not when a given
event occurs.
`var shiftKeyPressed = instanceOfMouseEvent.shiftKey`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey`"
[this]
(-> this (.shiftKey)))
(defn webkit-force-at-force-mouse-down
"Property.
MouseEvent.WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN is a proprietary,
static numeric property whose value is the minimum force necessary
a force click.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN`"
[this]
(-> this (.WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN)))
(defn set-webkit-force-at-force-mouse-down!
"Property.
MouseEvent.WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN is a proprietary,
static numeric property whose value is the minimum force necessary
a force click.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN`"
[this val]
(aset this "WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN" val))
(defn webkit-force-at-mouse-down
"Property.
MouseEvent.WEBKIT_FORCE_AT_MOUSE_DOWN is a proprietary, WebKit-specific,
numeric property whose value is the minimum force necessary for
normal click.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_MOUSE_DOWN`"
[this]
(-> this (.WEBKIT_FORCE_AT_MOUSE_DOWN)))
(defn set-webkit-force-at-mouse-down!
"Property.
MouseEvent.WEBKIT_FORCE_AT_MOUSE_DOWN is a proprietary, WebKit-specific,
numeric property whose value is the minimum force necessary for
normal click.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/WEBKIT_FORCE_AT_MOUSE_DOWN`"
[this val]
(aset this "WEBKIT_FORCE_AT_MOUSE_DOWN" val))
(defn webkit-force
"Property.
MouseEvent.webkitForce is a proprietary, WebKit-specific numeric
whose value represents the amount of pressure that is being applied
the touchpad or touchscreen.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/webkitForce`"
[this]
(-> this (.webkitForce)))
(defn set-webkit-force!
"Property.
MouseEvent.webkitForce is a proprietary, WebKit-specific numeric
whose value represents the amount of pressure that is being applied
the touchpad or touchscreen.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/webkitForce`"
[this val]
(aset this "webkitForce" val))
(defn which
"Property.
The MouseEvent.which read-only property indicates which button
pressed on the mouse to trigger the event. The standard alternatives
this property are `MouseEvent.button` and `MouseEvent.buttons`.
`var buttonPressed = instanceOfMouseEvent.which`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which`"
[this]
(-> this (.which)))