| 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 /** | 6 /** |
| 7 * An event that describes user interaction with the keyboard. | 7 * An event that describes user interaction with the keyboard. |
| 8 * | 8 * |
| 9 * The [type] of the event identifies what kind of interaction occurred. | 9 * The [type] of the event identifies what kind of interaction occurred. |
| 10 * | 10 * |
| 11 * See also: | 11 * See also: |
| 12 * | 12 * |
| 13 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN. | 13 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN. |
| 14 */ | 14 */ |
| 15 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 15 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 16 | 16 |
| 17 factory $CLASSNAME(String type, | 17 factory $CLASSNAME(String type, |
| 18 {Window view, bool canBubble: true, bool cancelable: true, | 18 {Window view, bool canBubble: true, bool cancelable: true, |
| 19 String keyIdentifier: "", int keyLocation: 1, bool ctrlKey: false, | 19 String keyIdentifier: "", int keyLocation: 1, bool ctrlKey: false, |
| 20 bool altKey: false, bool shiftKey: false, bool metaKey: false, | 20 bool altKey: false, bool shiftKey: false, bool metaKey: false, |
| 21 bool altGraphKey: false}) { | 21 bool altGraphKey: false}) { |
| 22 if (view == null) { | 22 if (view == null) { |
| 23 view = window; | 23 view = window; |
| 24 } | 24 } |
| 25 final e = document.$dom_createEvent("KeyboardEvent"); | 25 final e = document._createEvent("KeyboardEvent"); |
| 26 e.$dom_initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, | 26 e._initKeyboardEvent(type, canBubble, cancelable, view, keyIdentifier, |
| 27 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 27 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
| 28 return e; | 28 return e; |
| 29 } | 29 } |
| 30 | 30 |
| 31 @DomName('KeyboardEvent.initKeyboardEvent') | 31 @DomName('KeyboardEvent.initKeyboardEvent') |
| 32 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, | 32 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, |
| 33 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | 33 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, |
| 34 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { | 34 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { |
| 35 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { | 35 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { |
| 36 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has | 36 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has |
| 37 // a slightly different signature, and allows you to specify keyCode and | 37 // a slightly different signature, and allows you to specify keyCode and |
| 38 // charCode as the last two arguments, but we just set them as the default | 38 // charCode as the last two arguments, but we just set them as the default |
| 39 // since they can't be specified in other browsers. | 39 // since they can't be specified in other browsers. |
| 40 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, | 40 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, |
| 41 type, canBubble, cancelable, view, | 41 type, canBubble, cancelable, view, |
| 42 ctrlKey, altKey, shiftKey, metaKey); | 42 ctrlKey, altKey, shiftKey, metaKey); |
| 43 } else { | 43 } else { |
| 44 // initKeyboardEvent is for all other browsers. | 44 // initKeyboardEvent is for all other browsers. |
| 45 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, | 45 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, |
| 46 type, canBubble, cancelable, view, keyIdentifier, keyLocation, | 46 type, canBubble, cancelable, view, keyIdentifier, keyLocation, |
| 47 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 47 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 @DomName('KeyboardEvent.keyCode') | 51 @DomName('KeyboardEvent.keyCode') |
| 52 int get keyCode => $dom_keyCode; | 52 int get keyCode => _keyCode; |
| 53 | 53 |
| 54 @DomName('KeyboardEvent.charCode') | 54 @DomName('KeyboardEvent.charCode') |
| 55 int get charCode => $dom_charCode; | 55 int get charCode => _charCode; |
| 56 $!MEMBERS | 56 $!MEMBERS |
| 57 } | 57 } |
| OLD | NEW |