OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /// @domName KeyboardEvent; @docsEditable true | 6 @DomName('KeyboardEvent') |
7 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
8 | 8 |
9 factory $CLASSNAME(String type, Window view, | 9 factory $CLASSNAME(String type, Window view, |
10 [bool canBubble = true, bool cancelable = true, | 10 [bool canBubble = true, bool cancelable = true, |
11 String keyIdentifier = "", int keyLocation = 1, bool ctrlKey = false, | 11 String keyIdentifier = "", int keyLocation = 1, bool ctrlKey = false, |
12 bool altKey = false, bool shiftKey = false, bool metaKey = false, | 12 bool altKey = false, bool shiftKey = false, bool metaKey = false, |
13 bool altGraphKey = false]) { | 13 bool altGraphKey = false]) { |
14 final e = document.$dom_createEvent("KeyboardEvent"); | 14 final e = document.$dom_createEvent("KeyboardEvent"); |
15 e.$dom_initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, | 15 e.$dom_initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, |
16 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 16 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
17 return e; | 17 return e; |
18 } | 18 } |
19 | 19 |
20 /** @domName KeyboardEvent.initKeyboardEvent */ | 20 @DomName('KeyboardEvent.initKeyboardEvent') |
21 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, | 21 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, |
22 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | 22 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, |
23 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { | 23 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { |
24 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { | 24 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { |
25 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has | 25 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has |
26 // a slightly different signature, and allows you to specify keyCode and | 26 // a slightly different signature, and allows you to specify keyCode and |
27 // charCode as the last two arguments, but we just set them as the default | 27 // charCode as the last two arguments, but we just set them as the default |
28 // since they can't be specified in other browsers. | 28 // since they can't be specified in other browsers. |
29 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, | 29 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, |
30 type, canBubble, cancelable, view, | 30 type, canBubble, cancelable, view, |
31 ctrlKey, altKey, shiftKey, metaKey); | 31 ctrlKey, altKey, shiftKey, metaKey); |
32 } else { | 32 } else { |
33 // initKeyboardEvent is for all other browsers. | 33 // initKeyboardEvent is for all other browsers. |
34 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, | 34 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, |
35 type, canBubble, cancelable, view, keyIdentifier, keyLocation, | 35 type, canBubble, cancelable, view, keyIdentifier, keyLocation, |
36 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 36 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 /** @domName KeyboardEvent.keyCode */ | 40 @DomName('KeyboardEvent.keyCode') |
41 int get keyCode => $dom_keyCode; | 41 int get keyCode => $dom_keyCode; |
42 | 42 |
43 /** @domName KeyboardEvent.charCode */ | 43 @DomName('KeyboardEvent.charCode') |
44 int get charCode => $dom_charCode; | 44 int get charCode => $dom_charCode; |
45 $!MEMBERS | 45 $!MEMBERS |
46 } | 46 } |
OLD | NEW |