Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: tools/dom/templates/html/dart2js/impl_KeyboardEvent.darttemplate

Issue 23455033: Fully polyfill KeyEvent so that you can programmatically create your own "keyboard" events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
41 @DomName('KeyboardEvent.initKeyboardEvent') 47 @DomName('KeyboardEvent.initKeyboardEvent')
42 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, 48 void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
43 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, 49 Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
44 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) { 50 bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) {
45 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) { 51 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) {
46 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has 52 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has
47 // a slightly different signature, and allows you to specify keyCode and 53 // a slightly different signature, and allows you to specify keyCode and
48 // charCode as the last two arguments, but we just set them as the default 54 // charCode as the last two arguments, but we just set them as the default
49 // since they can't be specified in other browsers. 55 // since they can't be specified in other browsers.
50 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this, 56 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this,
51 type, canBubble, cancelable, view, 57 type, canBubble, cancelable, view,
52 ctrlKey, altKey, shiftKey, metaKey); 58 ctrlKey, altKey, shiftKey, metaKey);
53 } else { 59 } else {
54 // initKeyboardEvent is for all other browsers. 60 // initKeyboardEvent is for all other browsers.
55 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this, 61 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this,
56 type, canBubble, cancelable, view, keyIdentifier, keyLocation, 62 type, canBubble, cancelable, view, keyIdentifier, keyLocation,
57 ctrlKey, altKey, shiftKey, metaKey, altGraphKey); 63 ctrlKey, altKey, shiftKey, metaKey, altGraphKey);
58 } 64 }
59 } 65 }
60 66
61 @DomName('KeyboardEvent.keyCode') 67 @DomName('KeyboardEvent.keyCode')
62 int get keyCode => _keyCode; 68 int get keyCode => _keyCode;
63 69
64 @DomName('KeyboardEvent.charCode') 70 @DomName('KeyboardEvent.charCode')
65 int get charCode => _charCode; 71 int get charCode => _charCode;
66 $!MEMBERS 72 $!MEMBERS
67 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698