MouseEvent.webidl (5985B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * For more information on this interface please see 7 * http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html 8 * https://drafts.csswg.org/cssom-view/#extensions-to-the-mouseevent-interface 9 * 10 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 11 * liability, trademark and document use rules apply. 12 */ 13 14 interface nsIScreen; 15 16 [Exposed=Window] 17 interface MouseEvent : UIEvent { 18 constructor(DOMString typeArg, 19 optional MouseEventInit mouseEventInitDict = {}); 20 21 [NeedsCallerType] 22 readonly attribute double screenX; 23 [NeedsCallerType] 24 readonly attribute double screenY; 25 26 [ChromeOnly] 27 readonly attribute nsIScreen? screen; 28 29 readonly attribute double pageX; 30 readonly attribute double pageY; 31 readonly attribute double clientX; 32 readonly attribute double clientY; 33 [BinaryName="clientX"] 34 readonly attribute double x; 35 [BinaryName="clientY"] 36 readonly attribute double y; 37 readonly attribute double offsetX; 38 readonly attribute double offsetY; 39 readonly attribute boolean ctrlKey; 40 readonly attribute boolean shiftKey; 41 readonly attribute boolean altKey; 42 readonly attribute boolean metaKey; 43 readonly attribute short button; 44 readonly attribute unsigned short buttons; 45 readonly attribute EventTarget? relatedTarget; 46 47 // Pointer Lock 48 readonly attribute long movementX; 49 readonly attribute long movementY; 50 51 // Deprecated in DOM Level 3: 52 [Deprecated="InitMouseEvent"] 53 undefined initMouseEvent(DOMString typeArg, 54 optional boolean canBubbleArg = false, 55 optional boolean cancelableArg = false, 56 optional Window? viewArg = null, 57 optional long detailArg = 0, 58 optional long screenXArg = 0, 59 optional long screenYArg = 0, 60 optional long clientXArg = 0, 61 optional long clientYArg = 0, 62 optional boolean ctrlKeyArg = false, 63 optional boolean altKeyArg = false, 64 optional boolean shiftKeyArg = false, 65 optional boolean metaKeyArg = false, 66 optional short buttonArg = 0, 67 optional EventTarget? relatedTargetArg = null); 68 // Introduced in DOM Level 3: 69 boolean getModifierState(DOMString keyArg); 70 71 [ChromeOnly] 72 // The event that triggered this event. 73 // This will be available for popupshowing event only. 74 readonly attribute Event? triggerEvent; 75 }; 76 77 // Suggested initMouseEvent replacement initializer: 78 dictionary MouseEventInit : EventModifierInit { 79 // Attributes for MouseEvent: 80 double screenX = 0.0; 81 double screenY = 0.0; 82 double clientX = 0.0; 83 double clientY = 0.0; 84 short button = 0; 85 // Note: "buttons" was not previously initializable through initMouseEvent! 86 unsigned short buttons = 0; 87 EventTarget? relatedTarget = null; 88 89 // Pointer Lock 90 long movementX = 0; 91 long movementY = 0; 92 }; 93 94 // Mozilla extensions 95 partial interface MouseEvent 96 { 97 // Finger or touch pressure event value 98 // ranges between 0.0 and 1.0 99 // TODO: Remove mozPressure. (bug 1534199) 100 [NeedsCallerType, Deprecated="MouseEvent_MozPressure"] 101 readonly attribute float mozPressure; 102 103 const unsigned short MOZ_SOURCE_UNKNOWN = 0; 104 const unsigned short MOZ_SOURCE_MOUSE = 1; 105 const unsigned short MOZ_SOURCE_PEN = 2; 106 const unsigned short MOZ_SOURCE_ERASER = 3; 107 const unsigned short MOZ_SOURCE_CURSOR = 4; 108 const unsigned short MOZ_SOURCE_TOUCH = 5; 109 const unsigned short MOZ_SOURCE_KEYBOARD = 6; 110 111 [NeedsCallerType, ChromeOnly] 112 readonly attribute unsigned short inputSource; 113 114 [NeedsCallerType, Deprecated="MozInputSource", BinaryName="inputSource"] 115 readonly attribute unsigned short mozInputSource; 116 117 // TODO: Remove initNSMouseEvent. (bug 1165213) 118 [Deprecated="InitNSMouseEvent"] 119 undefined initNSMouseEvent(DOMString typeArg, 120 optional boolean canBubbleArg = false, 121 optional boolean cancelableArg = false, 122 optional Window? viewArg = null, 123 optional long detailArg = 0, 124 optional long screenXArg = 0, 125 optional long screenYArg = 0, 126 optional long clientXArg = 0, 127 optional long clientYArg = 0, 128 optional boolean ctrlKeyArg = false, 129 optional boolean altKeyArg = false, 130 optional boolean shiftKeyArg = false, 131 optional boolean metaKeyArg = false, 132 optional short buttonArg = 0, 133 optional EventTarget? relatedTargetArg = null, 134 optional float pressure = 0, 135 optional unsigned short inputSourceArg = 0); 136 137 /** 138 * preventClickEvent() prevents the following "click", "auxclick" and 139 * "dblclick" events of "mousedown" and "mouseup" events. 140 */ 141 [ChromeOnly] 142 undefined preventClickEvent(); 143 144 /** 145 * Returns true if the following "click", "auxclick" and "dblclick" 146 * events of "mousedown" and "mouseup" events are prevented. 147 */ 148 [ChromeOnly] 149 boolean clickEventPrevented(); 150 };