| 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 * |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 bool altGraphKey: false}) { | 31 bool altGraphKey: false}) { |
| 32 if (view == null) { | 32 if (view == null) { |
| 33 view = window; | 33 view = window; |
| 34 } | 34 } |
| 35 final e = document._createEvent("KeyboardEvent"); | 35 final e = document._createEvent("KeyboardEvent"); |
| 36 e._initKeyboardEvent(type, canBubble, cancelable, view, "", | 36 e._initKeyboardEvent(type, canBubble, cancelable, view, "", |
| 37 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 37 keyLocation, ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
| 38 return e; | 38 return e; |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** | |
| 42 * Used for KeyboardEvent polyfilling when programmatically constructing | |
| 43 * KeyEvents. | |
| 44 */ | |
| 45 $CLASSNAME._private() : super._private(); | |
| 46 | |
| 47 @DomName('KeyboardEvent.initKeyboardEvent') | 41 @DomName('KeyboardEvent.initKeyboardEvent') |
| 48 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, | 42 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, |
| 49 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | 43 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, |
| 50 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { | 44 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { |
| 51 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { | 45 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { |
| 52 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has | 46 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has |
| 53 // a slightly different signature, and allows you to specify keyCode and | 47 // a slightly different signature, and allows you to specify keyCode and |
| 54 // charCode as the last two arguments, but we just set them as the default | 48 // charCode as the last two arguments, but we just set them as the default |
| 55 // since they can't be specified in other browsers. | 49 // since they can't be specified in other browsers. |
| 56 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, | 50 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, |
| 57 type, canBubble, cancelable, view, | 51 type, canBubble, cancelable, view, |
| 58 ctrlKey, altKey, shiftKey, metaKey); | 52 ctrlKey, altKey, shiftKey, metaKey); |
| 59 } else { | 53 } else { |
| 60 // initKeyboardEvent is for all other browsers. | 54 // initKeyboardEvent is for all other browsers. |
| 61 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, | 55 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, |
| 62 type, canBubble, cancelable, view, keyIdentifier, keyLocation, | 56 type, canBubble, cancelable, view, keyIdentifier, keyLocation, |
| 63 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); | 57 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); |
| 64 } | 58 } |
| 65 } | 59 } |
| 66 | 60 |
| 67 @DomName('KeyboardEvent.keyCode') | 61 @DomName('KeyboardEvent.keyCode') |
| 68 int get keyCode => _keyCode; | 62 int get keyCode => _keyCode; |
| 69 | 63 |
| 70 @DomName('KeyboardEvent.charCode') | 64 @DomName('KeyboardEvent.charCode') |
| 71 int get charCode => _charCode; | 65 int get charCode => _charCode; |
| 72 $!MEMBERS | 66 $!MEMBERS |
| 73 } | 67 } |
| OLD | NEW |