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

Unified Diff: tools/dom/src/dartium_KeyEvent.dart

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, 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/src/dartium_KeyEvent.dart
diff --git a/tools/dom/src/dartium_KeyEvent.dart b/tools/dom/src/dartium_KeyEvent.dart
index 6be8d67ffbd36850fdff0fca274c0d821f43d26d..f225a9dc611b73844078ba3b02ea55b24413ae40 100644
--- a/tools/dom/src/dartium_KeyEvent.dart
+++ b/tools/dom/src/dartium_KeyEvent.dart
@@ -12,6 +12,7 @@
*/
part of html;
+@Experimental()
class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
KeyboardEvent _parent;
@@ -47,13 +48,28 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
bool get _realAltKey => _parent.altKey;
/** Construct a KeyEvent with [parent] as the event we're emulating. */
- KeyEvent(KeyboardEvent parent): super(parent) {
+ KeyEvent.wrap(KeyboardEvent parent): super(parent) {
_parent = parent;
_shadowAltKey = _realAltKey;
_shadowCharCode = _realCharCode;
_shadowKeyCode = _realKeyCode;
}
+ /** Programmatically create a new KeyEvent (and KeyboardEvent). */
+ KeyEvent(String type,
+ {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0,
+ int charCode: 0, int keyLocation: 1, bool ctrlKey: false,
+ bool altKey: false, bool shiftKey: false, bool metaKey: false,
+ bool altGraphKey: false}) {
+ _parent = new KeyboardEvent(type, view: view, canBubble: canBubble,
+ cancelable: cancelable, keyLocation: keyLocation, ctrlKey: ctrlKey,
+ altKey: altKey, shiftKey: shiftKey, metaKey: metaKey, altGraphKey:
+ altGraphKey);
+ _shadowAltKey = altKey;
+ _shadowCharCode = charCode;
+ _shadowKeyCode = keyCode;
+ }
+
/** Accessor to provide a stream of KeyEvents on the desired target. */
static EventStreamProvider<KeyEvent> keyDownEvent =
new _KeyboardEventHandler('keydown');

Powered by Google App Engine
This is Rietveld 408576698