OLD | NEW |
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 | 6 * KeyEvent tries to provide a higher level, more polished keyboard event |
7 * information on top of the "raw" [KeyboardEvent]. | 7 * information on top of the "raw" [KeyboardEvent]. |
8 * | 8 * |
9 * The mechanics of using KeyEvents is a little different from the underlying | 9 * The mechanics of using KeyEvents is a little different from the underlying |
10 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add | 10 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 _shadowKeyCode = _realKeyCode; | 73 _shadowKeyCode = _realKeyCode; |
74 _currentTarget = _parent.currentTarget == null? window : | 74 _currentTarget = _parent.currentTarget == null? window : |
75 _parent.currentTarget; | 75 _parent.currentTarget; |
76 } | 76 } |
77 | 77 |
78 /** Programmatically create a new KeyEvent (and KeyboardEvent). */ | 78 /** Programmatically create a new KeyEvent (and KeyboardEvent). */ |
79 factory KeyEvent(String type, | 79 factory KeyEvent(String type, |
80 {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0, | 80 {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0, |
81 int charCode: 0, int keyLocation: 1, bool ctrlKey: false, | 81 int charCode: 0, int keyLocation: 1, bool ctrlKey: false, |
82 bool altKey: false, bool shiftKey: false, bool metaKey: false, | 82 bool altKey: false, bool shiftKey: false, bool metaKey: false, |
83 bool altGraphKey: false, EventTarget currentTarget}) { | 83 EventTarget currentTarget}) { |
84 var parent = new KeyboardEvent(type, view: view, canBubble: canBubble, | 84 var parent = new KeyboardEvent(type, view: view, canBubble: canBubble, |
85 cancelable: cancelable, keyLocation: keyLocation, ctrlKey: ctrlKey, | 85 cancelable: cancelable, keyLocation: keyLocation, ctrlKey: ctrlKey, |
86 altKey: altKey, shiftKey: shiftKey, metaKey: metaKey, altGraphKey: | 86 altKey: altKey, shiftKey: shiftKey, metaKey: metaKey); |
87 altGraphKey); | |
88 var keyEvent = new KeyEvent.wrap(parent); | 87 var keyEvent = new KeyEvent.wrap(parent); |
89 keyEvent._shadowAltKey = altKey; | 88 keyEvent._shadowAltKey = altKey; |
90 keyEvent._shadowCharCode = charCode; | 89 keyEvent._shadowCharCode = charCode; |
91 keyEvent._shadowKeyCode = keyCode; | 90 keyEvent._shadowKeyCode = keyCode; |
92 keyEvent._currentTarget = currentTarget == null ? window : currentTarget; | 91 keyEvent._currentTarget = currentTarget == null ? window : currentTarget; |
93 return keyEvent; | 92 return keyEvent; |
94 } | 93 } |
95 | 94 |
96 /** Accessor to provide a stream of KeyEvents on the desired target. */ | 95 /** Accessor to provide a stream of KeyEvents on the desired target. */ |
97 static EventStreamProvider<KeyEvent> keyDownEvent = | 96 static EventStreamProvider<KeyEvent> keyDownEvent = |
98 new _KeyboardEventHandler('keydown'); | 97 new _KeyboardEventHandler('keydown'); |
99 /** Accessor to provide a stream of KeyEvents on the desired target. */ | 98 /** Accessor to provide a stream of KeyEvents on the desired target. */ |
100 static EventStreamProvider<KeyEvent> keyUpEvent = | 99 static EventStreamProvider<KeyEvent> keyUpEvent = |
101 new _KeyboardEventHandler('keyup'); | 100 new _KeyboardEventHandler('keyup'); |
102 /** Accessor to provide a stream of KeyEvents on the desired target. */ | 101 /** Accessor to provide a stream of KeyEvents on the desired target. */ |
103 static EventStreamProvider<KeyEvent> keyPressEvent = | 102 static EventStreamProvider<KeyEvent> keyPressEvent = |
104 new _KeyboardEventHandler('keypress'); | 103 new _KeyboardEventHandler('keypress'); |
105 | 104 |
106 /** The currently registered target for this event. */ | 105 /** The currently registered target for this event. */ |
107 EventTarget get currentTarget => _currentTarget; | 106 EventTarget get currentTarget => _currentTarget; |
108 | 107 |
109 /** True if the altGraphKey is pressed during this event. */ | |
110 bool get altGraphKey => _parent.altGraphKey; | |
111 /** Accessor to the clipboardData available for this event. */ | 108 /** Accessor to the clipboardData available for this event. */ |
112 DataTransfer get clipboardData => _parent.clipboardData; | 109 DataTransfer get clipboardData => _parent.clipboardData; |
113 /** True if the ctrl key is pressed during this event. */ | 110 /** True if the ctrl key is pressed during this event. */ |
114 bool get ctrlKey => _parent.ctrlKey; | 111 bool get ctrlKey => _parent.ctrlKey; |
115 int get detail => _parent.detail; | 112 int get detail => _parent.detail; |
116 /** | 113 /** |
117 * Accessor to the part of the keyboard that the key was pressed from (one of | 114 * Accessor to the part of the keyboard that the key was pressed from (one of |
118 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, | 115 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, |
119 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). | 116 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). |
120 */ | 117 */ |
(...skipping 11 matching lines...) Expand all Loading... |
132 } | 129 } |
133 String get _shadowKeyIdentifier => _parent._keyIdentifier; | 130 String get _shadowKeyIdentifier => _parent._keyIdentifier; |
134 | 131 |
135 int get _charCode => charCode; | 132 int get _charCode => charCode; |
136 int get _keyCode => keyCode; | 133 int get _keyCode => keyCode; |
137 String get _keyIdentifier { | 134 String get _keyIdentifier { |
138 throw new UnsupportedError("keyIdentifier is unsupported."); | 135 throw new UnsupportedError("keyIdentifier is unsupported."); |
139 } | 136 } |
140 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, | 137 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, |
141 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | 138 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, |
142 bool altKey, bool shiftKey, bool metaKey, | 139 bool altKey, bool shiftKey, bool metaKey) { |
143 bool altGraphKey) { | |
144 throw new UnsupportedError( | 140 throw new UnsupportedError( |
145 "Cannot initialize a KeyboardEvent from a KeyEvent."); | 141 "Cannot initialize a KeyboardEvent from a KeyEvent."); |
146 } | 142 } |
147 int get _layerX => throw new UnsupportedError('Not applicable to KeyEvent'); | 143 int get _layerX => throw new UnsupportedError('Not applicable to KeyEvent'); |
148 int get _layerY => throw new UnsupportedError('Not applicable to KeyEvent'); | 144 int get _layerY => throw new UnsupportedError('Not applicable to KeyEvent'); |
149 int get _pageX => throw new UnsupportedError('Not applicable to KeyEvent'); | 145 int get _pageX => throw new UnsupportedError('Not applicable to KeyEvent'); |
150 int get _pageY => throw new UnsupportedError('Not applicable to KeyEvent'); | 146 int get _pageY => throw new UnsupportedError('Not applicable to KeyEvent'); |
151 @Experimental() // untriaged | 147 @Experimental() // untriaged |
152 bool getModifierState(String keyArgument) => throw new UnimplementedError(); | 148 bool getModifierState(String keyArgument) => throw new UnimplementedError(); |
153 @Experimental() // untriaged | 149 @Experimental() // untriaged |
154 int get location => throw new UnimplementedError(); | 150 int get location => throw new UnimplementedError(); |
155 @Experimental() // untriaged | 151 @Experimental() // untriaged |
156 bool get repeat => throw new UnimplementedError(); | 152 bool get repeat => throw new UnimplementedError(); |
157 dynamic get _get_view => throw new UnimplementedError(); | 153 dynamic get _get_view => throw new UnimplementedError(); |
158 } | 154 } |
OLD | NEW |