OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 -- Copyright 2013 The Chromium Authors. All rights reserved. | 2 -- Copyright 2013 The Chromium Authors. All rights reserved. |
3 -- Use of this source code is governed by a BSD-style license that can be | 3 -- Use of this source code is governed by a BSD-style license that can be |
4 -- found in the LICENSE file. | 4 -- found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" | 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" |
8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" | 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" |
9 on-pointerdown="down" on-enable-sel="enableSel" | 9 on-pointerdown="down" on-enable-sel="enableSel" |
10 on-enable-dbl="enableDbl" on-key-out="keyOut" | 10 on-enable-dbl="enableDbl" on-key-out="keyOut" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 shift: null, | 205 shift: null, |
206 inputType: null, | 206 inputType: null, |
207 | 207 |
208 /** | 208 /** |
209 * The default input type to keyboard layout map. The key must be one of | 209 * The default input type to keyboard layout map. The key must be one of |
210 * the input box type values. | 210 * the input box type values. |
211 * @type {object} | 211 * @type {object} |
212 */ | 212 */ |
213 inputTypeToLayoutMap: { | 213 inputTypeToLayoutMap: { |
214 number: "numeric", | 214 number: "numeric", |
215 text: "qwerty" | 215 text: "qwerty", |
216 password: "system-qwerty" //TODO(rsadam@): Add unit test for this. | |
216 }, | 217 }, |
217 | 218 |
218 /** | 219 /** |
219 * Changes the current keyset. | 220 * Changes the current keyset. |
220 * @param {Object} detail The detail of the event that called this | 221 * @param {Object} detail The detail of the event that called this |
221 * function. | 222 * function. |
222 */ | 223 */ |
223 changeKeyset: function(detail) { | 224 changeKeyset: function(detail) { |
224 if (detail.relegateToShift && this.shift) { | 225 if (detail.relegateToShift && this.shift) { |
225 this.keyset = this.shift.textKeyset; | 226 this.keyset = this.shift.textKeyset; |
(...skipping 12 matching lines...) Expand all Loading... | |
238 ready: function() { | 239 ready: function() { |
239 this.voiceInput_ = new VoiceInput(this); | 240 this.voiceInput_ = new VoiceInput(this); |
240 this.swipeHandler = this.onSwipeUpdate.bind(this); | 241 this.swipeHandler = this.onSwipeUpdate.bind(this); |
241 }, | 242 }, |
242 | 243 |
243 /** | 244 /** |
244 * Called when the type of focused input box changes. If a keyboard layout | 245 * Called when the type of focused input box changes. If a keyboard layout |
245 * is defined for the current input type, that layout will be loaded. | 246 * is defined for the current input type, that layout will be loaded. |
246 * Otherwise, the keyboard layout for 'text' type will be loaded. | 247 * Otherwise, the keyboard layout for 'text' type will be loaded. |
247 */ | 248 */ |
248 inputTypeChanged: function() { | 249 inputTypeChanged: function() { |
bshe
2013/10/09 19:42:55
we can probably just override inputType setter and
rsadam
2013/10/09 20:18:46
As we discussed offline, that will cause timing is
| |
249 // TODO(bshe): Toggle visibility of some keys in a keyboard layout | 250 // TODO(bshe): Toggle visibility of some keys in a keyboard layout |
250 // according to the input type. | 251 // according to the input type. |
251 var layout = this.inputTypeToLayoutMap[this.inputType]; | 252 var layout = this.inputTypeToLayoutMap[this.inputType]; |
252 if (!layout) | 253 if (!layout) |
253 layout = this.inputTypeToLayoutMap.text; | 254 layout = this.inputTypeToLayoutMap.text; |
254 // Reselects the default keyset if target layout is the same as current | 255 this.layout = layout; |
255 // layout. This forces a reset of the keyboard state. | |
256 if(this.layout == layout) | |
257 this.selectDefaultKeyset(); | |
258 else | |
259 this.layout = layout; | |
260 }, | 256 }, |
261 | 257 |
262 /** | 258 /** |
263 * When double click/tap event is enabled, the second key-down and key-up | 259 * When double click/tap event is enabled, the second key-down and key-up |
264 * events on the same key should be skipped. Return true when the event | 260 * events on the same key should be skipped. Return true when the event |
265 * with |detail| should be skipped. | 261 * with |detail| should be skipped. |
266 * @param {Object} detail The detail of key-up or key-down event. | 262 * @param {Object} detail The detail of key-up or key-down event. |
267 */ | 263 */ |
268 skipEvent: function(detail) { | 264 skipEvent: function(detail) { |
269 if (this.dblDetail_) { | 265 if (this.dblDetail_) { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 | 585 |
590 /** | 586 /** |
591 * The active keyset DOM object. | 587 * The active keyset DOM object. |
592 * @type {kb-keyset} | 588 * @type {kb-keyset} |
593 */ | 589 */ |
594 get activeKeyset() { | 590 get activeKeyset() { |
595 return this.querySelector('#' + this.activeKeysetId); | 591 return this.querySelector('#' + this.activeKeysetId); |
596 }, | 592 }, |
597 | 593 |
598 /** | 594 /** |
595 * The current input type. | |
596 * @type {string} | |
597 */ | |
598 get inputTypeValue() { | |
599 return inputType; | |
600 }, | |
601 | |
602 /** | |
603 * Changes the input type if it's different from the current | |
604 * type, else resets the keyset to the default keyset. | |
605 * @type {string} | |
606 */ | |
607 set inputTypeValue(value) { | |
608 if (value == this.inputType) | |
609 this.selectDefaultKeyset(); | |
610 else | |
611 this.inputType = value; | |
612 }, | |
613 | |
614 /** | |
599 * Generates fabricated key events to simulate typing on a | 615 * Generates fabricated key events to simulate typing on a |
600 * physical keyboard. | 616 * physical keyboard. |
601 * @param {Object} detail Attributes of the key being typed. | 617 * @param {Object} detail Attributes of the key being typed. |
602 */ | 618 */ |
603 keyTyped: function(detail) { | 619 keyTyped: function(detail) { |
604 var builder = this.$.keyCodeMetadata; | 620 var builder = this.$.keyCodeMetadata; |
605 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keydown")); | 621 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keydown")); |
606 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keyup")); | 622 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keyup")); |
607 }, | 623 }, |
608 | 624 |
(...skipping 26 matching lines...) Expand all Loading... | |
635 } | 651 } |
636 } | 652 } |
637 } | 653 } |
638 if (keysetsLoaded) | 654 if (keysetsLoaded) |
639 console.error('No default keyset found for ' + this.layout); | 655 console.error('No default keyset found for ' + this.layout); |
640 return false; | 656 return false; |
641 } | 657 } |
642 }); | 658 }); |
643 </script> | 659 </script> |
644 </polymer-element> | 660 </polymer-element> |
OLD | NEW |