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'); |