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

Side by Side Diff: sdk/lib/html/src/dartium_KeyEvent.dart

Issue 11416249: Make KeyboardEvent cross-browser consistent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: moved instance variables to constructor Created 8 years 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
(Empty)
1 /**
2 * A custom KeyboardEvent that attempts to eliminate cross-browser
3 * inconsistencies, and also provide both keyCode and charCode information
4 * for all key events (when such information can be determined).
5 *
6 * 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
8 * possible. Bugs welcome!
9 */
10 class KeyEvent implements KeyboardEvent {
11 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
12 KeyboardEvent _parent;
13
14 /** The "fixed" value of whether the alt key is being pressed. */
15 bool _shadowAltKey;
16
17 /** Caculated value of what the estimated charCode is for this event. */
18 int _shadowCharCode;
19
20 /** Caculated value of what the estimated keyCode is for this event. */
21 int _shadowKeyCode;
22
23 /** Caculated value of what the estimated keyCode is for this event. */
24 int get keyCode => _shadowKeyCode;
25
26 /** Caculated value of what the estimated charCode is for this event. */
27 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0;
28
29 /** Caculated value of whether the alt key is pressed is for this event. */
30 bool get altKey => _shadowAltKey;
31
32 /** Caculated value of what the estimated keyCode is for this event. */
33 int get which => keyCode;
34
35 /** Accessor to the underlying keyCode value is the parent event. */
36 int get _realKeyCode => _parent.keyCode;
37
38 /** Accessor to the underlying charCode value is the parent event. */
39 int get _realCharCode => _parent.charCode;
40
41 /** Accessor to the underlying altKey value is the parent event. */
42 bool get _realAltKey => _parent.altKey;
43
44 /** Construct a KeyEvent with [parent] as event we're emulating. */
45 KeyEvent(KeyboardEvent parent) {
46 _parent = parent;
47 _shadowAltKey = _realAltKey;
48 _shadowCharCode = _realCharCode;
49 _shadowKeyCode = _realKeyCode;
50 }
51
52 /** True if the altGraphKey is pressed during this event. */
53 bool get altGraphKey => _parent.altGraphKey;
54 bool get bubbles => _parent.bubbles;
55 /** True if this event can be cancelled. */
56 bool get cancelable => _parent.cancelable;
57 bool get cancelBubble => _parent.cancelBubble;
58 set cancelBubble(bool cancel) => _parent = cancel;
59 /** Accessor to the clipboardData available for this event. */
60 Clipboard get clipboardData => _parent.clipboardData;
61 /** True if the ctrl key is pressed during this event. */
62 bool get ctrlKey => _parent.ctrlKey;
63 /** Accessor to the target this event is listening to for changes. */
64 EventTarget get currentTarget => _parent.currentTarget;
65 bool get defaultPrevented => _parent.defaultPrevented;
66 int get detail => _parent.detail;
67 int get eventPhase => _parent.eventPhase;
68 /**
69 * Accessor to the part of the keyboard that the key was pressed from (one of
70 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
71 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
72 */
73 int get keyLocation => _parent.keyLocation;
74 int get layerX => _parent.layerX;
75 int get layerY => _parent.layerY;
76 /** True if the Meta (or Mac command) key is pressed during this event. */
77 bool get metaKey => _parent.metaKey;
78 int get pageX => _parent.pageX;
79 int get pageY => _parent.pageY;
80 bool get returnValue => _parent.returnValue;
81 set returnValue(bool value) => _parent = value;
82 /** True if the shift key was pressed during this event. */
83 bool get shiftKey => _parent.shiftKey;
84 int get timeStamp => _parent.timeStamp;
85 /**
86 * The type of key event that occurred. One of "keydown", "keyup", or
87 * "keypress".
88 */
89 String get type => _parent.type;
90 Window get view => _parent.view;
91 void preventDefault() => _parent.preventDefault();
92 void stopImmediatePropagation() => _parent.stopImmediatePropagation();
93 void stopPropagation() => _parent.stopPropagation();
94 void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
95 LocalWindow view, int detail) {
96 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
97 }
98 void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
99 bool cancelableArg) {
100 throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
101 }
102 String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier;
103 }
OLDNEW
« no previous file with comments | « sdk/lib/html/src/dart2js_KeyEvent.dart ('k') | sdk/lib/html/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698