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

Side by Side Diff: tools/dom/src/dartium_KeyEvent.dart

Issue 12419011: Modern-ify KeyEvent handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 /** 1 /**
2 * A custom KeyboardEvent that attempts to eliminate cross-browser 2 * A custom KeyboardEvent that attempts to eliminate cross-browser
3 * inconsistencies, and also provide both keyCode and charCode information 3 * inconsistencies, and also provide both keyCode and charCode information
4 * for all key events (when such information can be determined). 4 * for all key events (when such information can be determined).
5 * 5 *
6 * KeyEvent tries to provide a higher level, more polished keyboard event
7 * information on top of the "raw" [KeyboardEvent].
8 *
6 * This class is very much a work in progress, and we'd love to get information 9 * This class is very much a work in progress, and we'd love to get information
7 * on how we can make this class work with as many international keyboards as 10 * on how we can make this class work with as many international keyboards as
8 * possible. Bugs welcome! 11 * possible. Bugs welcome!
9 */ 12 */
10 class KeyEvent implements KeyboardEvent { 13 class KeyEvent implements KeyboardEvent {
11 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */ 14 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
12 KeyboardEvent _parent; 15 KeyboardEvent _parent;
13 16
14 /** The "fixed" value of whether the alt key is being pressed. */ 17 /** The "fixed" value of whether the alt key is being pressed. */
15 bool _shadowAltKey; 18 bool _shadowAltKey;
(...skipping 18 matching lines...) Expand all
34 37
35 /** Accessor to the underlying keyCode value is the parent event. */ 38 /** Accessor to the underlying keyCode value is the parent event. */
36 int get _realKeyCode => _parent.keyCode; 39 int get _realKeyCode => _parent.keyCode;
37 40
38 /** Accessor to the underlying charCode value is the parent event. */ 41 /** Accessor to the underlying charCode value is the parent event. */
39 int get _realCharCode => _parent.charCode; 42 int get _realCharCode => _parent.charCode;
40 43
41 /** Accessor to the underlying altKey value is the parent event. */ 44 /** Accessor to the underlying altKey value is the parent event. */
42 bool get _realAltKey => _parent.altKey; 45 bool get _realAltKey => _parent.altKey;
43 46
44 /** Construct a KeyEvent with [parent] as event we're emulating. */ 47 /** Construct a KeyEvent with [parent] as the event we're emulating. */
45 KeyEvent(KeyboardEvent parent) { 48 KeyEvent(KeyboardEvent parent) {
46 _parent = parent; 49 _parent = parent;
47 _shadowAltKey = _realAltKey; 50 _shadowAltKey = _realAltKey;
48 _shadowCharCode = _realCharCode; 51 _shadowCharCode = _realCharCode;
49 _shadowKeyCode = _realKeyCode; 52 _shadowKeyCode = _realKeyCode;
50 } 53 }
51 54
55 /** Accessor to provide a stream of KeyEvents on the desired target. */
56 static EventStreamProvider<KeyEvent> keyDownEvent =
57 _KeyboardEventHandler('keydown');
58 /** Accessor to provide a stream of KeyEvents on the desired target. */
59 static EventStreamProvider<KeyEvent> keyUpEvent =
60 _KeyboardEventHandler('keyup');
61 /** Accessor to provide a stream of KeyEvents on the desired target. */
62 static EventStreamProvider<KeyEvent> keyPressEvent =
63 _KeyboardEventHandler('keypress');
64
52 /** True if the altGraphKey is pressed during this event. */ 65 /** True if the altGraphKey is pressed during this event. */
53 bool get altGraphKey => _parent.altGraphKey; 66 bool get altGraphKey => _parent.altGraphKey;
54 bool get bubbles => _parent.bubbles; 67 bool get bubbles => _parent.bubbles;
55 /** True if this event can be cancelled. */ 68 /** True if this event can be cancelled. */
56 bool get cancelable => _parent.cancelable; 69 bool get cancelable => _parent.cancelable;
57 bool get cancelBubble => _parent.cancelBubble; 70 bool get cancelBubble => _parent.cancelBubble;
58 void set cancelBubble(bool cancel) { 71 void set cancelBubble(bool cancel) {
59 _parent.cancelBubble = cancel; 72 _parent.cancelBubble = cancel;
60 } 73 }
61 /** Accessor to the clipboardData available for this event. */ 74 /** Accessor to the clipboardData available for this event. */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 throw new UnsupportedError("keyIdentifier is unsupported."); 123 throw new UnsupportedError("keyIdentifier is unsupported.");
111 } 124 }
112 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable, 125 void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable,
113 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, 126 Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
114 bool altKey, bool shiftKey, bool metaKey, 127 bool altKey, bool shiftKey, bool metaKey,
115 bool altGraphKey) { 128 bool altGraphKey) {
116 throw new UnsupportedError( 129 throw new UnsupportedError(
117 "Cannot initialize a KeyboardEvent from a KeyEvent."); 130 "Cannot initialize a KeyboardEvent from a KeyEvent.");
118 } 131 }
119 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698