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

Side by Side Diff: ui/keyboard/resources/elements/kb-keyboard.html

Issue 23332022: Virtual Keyboard Shift Highlight fixed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed style issues. Now uses double quotes. Created 7 years, 3 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
« no previous file with comments | « no previous file | ui/keyboard/resources/layouts/dvorak.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" attributes="keyset layout rows"> 10 on-enable-dbl="enableDbl" attributes="keyset layout rows">
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 lastPressedKey: null, 176 lastPressedKey: null,
177 voiceInput_: null, 177 voiceInput_: null,
178 dblDetail_: null, 178 dblDetail_: null,
179 dblTimer_: null, 179 dblTimer_: null,
180 swipeHandler: null, 180 swipeHandler: null,
181 181
182 /** 182 /**
183 * Handles the state of the shift key. 183 * Handles the state of the shift key.
184 */ 184 */
185 keysetChanged: function() { 185 keysetChanged: function() {
186 // TODO (rsadam): Generalize to avoid the need to hardcode upper. Add 186 var keysetId = '#' + this.layout + '-' + this.keyset;
187 // state attribute to shift key. 187 var keyset = this.querySelector(keysetId);
188 if (this.keyset == 'upper') { 188
189 // Deals with the edge case where caps was triggered by a long press. 189 // Unlocks the keyboard if the current keyset is not lockable.
190 // Do not want to highlight the shift key in this case. 190 if (!keyset.getAttribute('lockable'))
191 if (!this.classList.contains('caps')) 191 this.classList.remove('locked');
192 this.classList.add('highlight'); 192
193 } else {
194 this.classList.remove('highlight');
195 this.classList.remove('caps');
196 }
197 }, 193 },
198 194
199 ready: function() { 195 ready: function() {
200 this.voiceInput_ = new VoiceInput(this); 196 this.voiceInput_ = new VoiceInput(this);
201 this.swipeHandler = this.onSwipeUpdate.bind(this); 197 this.swipeHandler = this.onSwipeUpdate.bind(this);
202 }, 198 },
203 199
204 /** 200 /**
205 * When double click/tap event is enabled, the second key-down and key-up 201 * When double click/tap event is enabled, the second key-down and key-up
206 * events on the same key should be skipped. Return true when the event 202 * events on the same key should be skipped. Return true when the event
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 /** 336 /**
341 * Handles pointerup event. This is used for double tap/click events. 337 * Handles pointerup event. This is used for double tap/click events.
342 * @param {PointerEvent} event The pointerup event that bubbled to 338 * @param {PointerEvent} event The pointerup event that bubbled to
343 * kb-keyboard. 339 * kb-keyboard.
344 */ 340 */
345 up: function(event) { 341 up: function(event) {
346 if (this.dblDetail_) { 342 if (this.dblDetail_) {
347 this.dblDetail_.clickCount++; 343 this.dblDetail_.clickCount++;
348 if (this.dblDetail_.clickCount == 2) { 344 if (this.dblDetail_.clickCount == 2) {
349 this.keyset = this.dblDetail_.toKeyset; 345 this.keyset = this.dblDetail_.toKeyset;
350 var keysetId = '#' + this.layout + '-' + this.keyset 346 var keysetId = '#' + this.layout + '-' + this.keyset;
351 this.querySelector(keysetId).nextKeyset = this.dblTimer_.nextKeyset; 347 var keyset = this.querySelector(keysetId);
348 keyset.nextKeyset = this.dblTimer_.nextKeyset;
352 clearTimeout(this.dblTimer_); 349 clearTimeout(this.dblTimer_);
353 350
354 // Checks if shift is capitalized. 351 // Checks if shift is capitalized.
355 if (this.keyset == 'upper') { 352 if (keyset.getAttribute('lockable'))
356 this.classList.remove('highlight'); 353 this.classList.add('locked');
357 this.classList.add('caps');
358 }
359 354
360 this.dblDetail_ = null; 355 this.dblDetail_ = null;
361 } 356 }
362 } 357 }
363 358
364 // TODO(zyaozhujun): There are some edge cases to deal with later. 359 // TODO(zyaozhujun): There are some edge cases to deal with later.
365 // (for instance, what if a second finger trigger a down and up 360 // (for instance, what if a second finger trigger a down and up
366 // event sequence while swiping). 361 // event sequence while swiping).
367 // When pointer up from the screen, a swipe selection session finished, 362 // When pointer up from the screen, a swipe selection session finished,
368 // all the data should be reset to prepare for the next session. 363 // all the data should be reset to prepare for the next session.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 keyLongpress: function(event, detail) { 430 keyLongpress: function(event, detail) {
436 // If the gesture is long press, remove the pointermove listener. 431 // If the gesture is long press, remove the pointermove listener.
437 this.removeEventListener('pointermove', this.swipeHandler, false); 432 this.removeEventListener('pointermove', this.swipeHandler, false);
438 var toKeyset = detail.toKeyset; 433 var toKeyset = detail.toKeyset;
439 // Keyset transtion key. 434 // Keyset transtion key.
440 if (toKeyset) { 435 if (toKeyset) {
441 this.keyset = toKeyset; 436 this.keyset = toKeyset;
442 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = 437 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
443 detail.nextKeyset; 438 detail.nextKeyset;
444 439
445 // Sets the caps class before removing active to prevent flicker. 440 // Locks the keyset before removing active to prevent flicker.
446 this.classList.add('caps'); 441 this.classList.add('locked');
447 // Makes last pressed key inactive if transit to a new keyset on long 442 // Makes last pressed key inactive if transit to a new keyset on long
448 // press. 443 // press.
449 this.lastPressedKey.classList.remove('active'); 444 this.lastPressedKey.classList.remove('active');
450 } 445 }
451 }, 446 },
452 447
453 /** 448 /**
454 * Handles a change in the keyboard layout. Auto-selects the default 449 * Handles a change in the keyboard layout. Auto-selects the default
455 * keyset for the new layout. 450 * keyset for the new layout.
456 */ 451 */
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 483 }
489 } 484 }
490 if (keysetsLoaded) 485 if (keysetsLoaded)
491 console.error('No default keyset found for ' + this.layout); 486 console.error('No default keyset found for ' + this.layout);
492 return false; 487 return false;
493 } 488 }
494 }); 489 });
495 </script> 490 </script>
496 </polymer-element> 491 </polymer-element>
497 492
OLDNEW
« no previous file with comments | « no previous file | ui/keyboard/resources/layouts/dvorak.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698