blob: d7a6d1768f9ff0f54b1193d41135635e41e7165e (
plain)
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
|
---
title: UIEvent
slug: Web/API/UIEvent
tags:
- 待翻譯
translation_of: Web/API/UIEvent
---
<p>{{APIRef("DOM Events")}}</p>
<p><strong><code>UIEvent</code></strong> 介面是使用者介面的事件的基本型態。</p>
<p><code>UIEvent</code> 是從 {{domxref("Event")}} 衍伸過來。 雖然為了相容性,仍留著 {{domxref("UIEvent.initUIEvent()")}} 方法,建立 <code>UIEvent</code> 物件最好是選擇以 {{domxref("UIEvent.UIEvent", "UIEvent()")}} constructor 建立。</p>
<p>許多介面直接或間接繼承此介面,例如:{{domxref("MouseEvent")}}、{{domxref("TouchEvent")}}、{{domxref("FocusEvent")}}、{{domxref("KeyboardEvent")}}、{{domxref("WheelEvent")}}、{{domxref("InputEvent")}} 和 {{domxref("CompositionEvent")}}。</p>
<h2 id="建構式">建構式</h2>
<dl>
<dt>{{domxref("UIEvent.UIEvent()", "UIEvent()")}}</dt>
<dd>建立一個 <code>UIEvent</code> 物件 。</dd>
</dl>
<h2 id="屬性">屬性</h2>
<p><em>此介面亦繼承其父-- {{domxref("Event")}} 的屬性:</em></p>
<dl>
<dt>{{domxref("UIEvent.cancelBubble")}} {{Non-standard_inline}} {{Deprecated_inline}}</dt>
<dd>Is a {{jsxref("Boolean")}} indicating whether the bubbling of the event has been canceled or not.</dd>
</dl>
<dl>
<dt>{{domxref("UIEvent.detail")}}{{readonlyinline}}</dt>
<dd>Returns a <code>long</code> with details about the event, depending on the event type.</dd>
<dt>{{domxref("UIEvent.isChar")}} {{obsolete_inline}} {{readonlyinline}}</dt>
<dd>Returns a {{jsxref("Boolean")}} indicating whether the event produced a key character or not.</dd>
<dt>{{domxref("UIEvent.layerX")}} {{Non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns the horizontal coordinate of the event relative to the current layer.</dd>
<dt>{{domxref("UIEvent.layerY")}} {{Non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns the vertical coordinate of the event relative to the current layer.</dd>
<dt>{{domxref("UIEvent.pageX")}} {{Non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns the horizontal coordinate of the event relative to the whole document.</dd>
<dt>{{domxref("UIEvent.pageY")}} {{Non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns the vertical coordinate of the event relative to the whole document.</dd>
<dt>{{domxref("UIEvent.sourceCapabilities")}} {{non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns an instance of the InputDeviceCapabilities interface which provides information about the physical device responsible for generating a touch event.</dd>
<dt>{{domxref("UIEvent.view")}}{{readonlyinline}}</dt>
<dd>Returns a {{domxref("WindowProxy")}} that contains the view that generated the event.</dd>
<dt>{{domxref("UIEvent.which")}} {{Non-standard_inline}} {{readonlyinline}}</dt>
<dd>Returns the numeric <code>keyCode</code> of the key pressed, or the character code (<code>charCode</code>) for an alphanumeric key pressed.</dd>
</dl>
<h2 id="方法">方法</h2>
<p><em>此介面亦繼承其父-- {{domxref("Event")}} 的方法:</em></p>
<dl>
<dt>{{domxref("UIEvent.initUIEvent()")}} {{deprecated_inline}}</dt>
<dd>初始化 <code>UIEvent</code> 物件。若該事件已經觸發的話,此方法就不會執行任何東西。</dd>
</dl>
<h2 id="規範">規範</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('InputDeviceCapabilities')}}</td>
<td>{{Spec2('InputDeviceCapabilities')}}</td>
<td>Added <code>sourceCapabilities</code> property.</td>
</tr>
<tr>
<td>{{SpecName('DOM3 Events', '#interface-UIEvent', 'UIEvent')}}</td>
<td>{{Spec2('DOM3 Events')}}</td>
<td>Added the <code>UIEvent()</code> constructor, deprecated the <code>initUIEvent()</code> method and changed the type of <code>view</code> from <code>AbstractView</code> to <code>WindowProxy</code>.</td>
</tr>
<tr>
<td>{{SpecName('DOM2 Events', '#Events-UIEvent', 'UIEvent')}}</td>
<td>{{Spec2('DOM2 Events')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">瀏覽器相容性</h2>
{{Compat("api.UIEvent")}}
<h2 class="editable" id="參見"><span>參見</span></h2>
<ul>
<li><a href="/en-US/docs/Learn/JavaScript/Building_blocks/Events">Introduction to events</a></li>
<li>{{domxref("Event")}}</li>
</ul>
|