| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of html; | 5 part of html; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Internal class that does the actual calculations to determine keyCode and | 8 * Internal class that does the actual calculations to determine keyCode and |
| 9 * charCode for keydown, keypress, and keyup events for all browsers. | 9 * charCode for keydown, keypress, and keyup events for all browsers. |
| 10 */ | 10 */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 var handler = new _KeyboardEventHandler.initializeAllEventListeners( | 69 var handler = new _KeyboardEventHandler.initializeAllEventListeners( |
| 70 _type, e); | 70 _type, e); |
| 71 return handler._stream; | 71 return handler._stream; |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * General constructor, performs basic initialization for our improved | 75 * General constructor, performs basic initialization for our improved |
| 76 * KeyboardEvent controller. | 76 * KeyboardEvent controller. |
| 77 */ | 77 */ |
| 78 _KeyboardEventHandler(this._type): super(_EVENT_TYPE), | 78 _KeyboardEventHandler(this._type): super(_EVENT_TYPE), |
| 79 _stream = new _CustomKeyEventStreamImpl('event'); | 79 _stream = new _CustomKeyEventStreamImpl('event'), _target = null; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Hook up all event listeners under the covers so we can estimate keycodes | 82 * Hook up all event listeners under the covers so we can estimate keycodes |
| 83 * and charcodes when they are not provided. | 83 * and charcodes when they are not provided. |
| 84 */ | 84 */ |
| 85 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) : | 85 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) : |
| 86 super(_EVENT_TYPE) { | 86 super(_EVENT_TYPE) { |
| 87 Element.keyDownEvent.forTarget(_target, useCapture: true).listen( | 87 Element.keyDownEvent.forTarget(_target, useCapture: true).listen( |
| 88 processKeyDown); | 88 processKeyDown); |
| 89 Element.keyPressEvent.forTarget(_target, useCapture: true).listen( | 89 Element.keyPressEvent.forTarget(_target, useCapture: true).listen( |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 new _KeyboardEventHandler('keypress').forTarget(target); | 372 new _KeyboardEventHandler('keypress').forTarget(target); |
| 373 | 373 |
| 374 /** Named constructor to produce a stream for onKeyUp events. */ | 374 /** Named constructor to produce a stream for onKeyUp events. */ |
| 375 static CustomStream<KeyEvent> onKeyUp(EventTarget target) => | 375 static CustomStream<KeyEvent> onKeyUp(EventTarget target) => |
| 376 new _KeyboardEventHandler('keyup').forTarget(target); | 376 new _KeyboardEventHandler('keyup').forTarget(target); |
| 377 | 377 |
| 378 /** Named constructor to produce a stream for onKeyDown events. */ | 378 /** Named constructor to produce a stream for onKeyDown events. */ |
| 379 static CustomStream<KeyEvent> onKeyDown(EventTarget target) => | 379 static CustomStream<KeyEvent> onKeyDown(EventTarget target) => |
| 380 new _KeyboardEventHandler('keydown').forTarget(target); | 380 new _KeyboardEventHandler('keydown').forTarget(target); |
| 381 } | 381 } |
| OLD | NEW |