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

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

Issue 23621045: Layout transitions triggered on key-down instead of key-up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits. 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 | « ui/keyboard/resources/elements/kb-key.html ('k') | 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 capsLocked"> 10 on-enable-dbl="enableDbl" attributes="keyset layout rows capsLocked">
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 */ 282 */
283 keyDown: function(event, detail) { 283 keyDown: function(event, detail) {
284 if (this.skipEvent(detail)) 284 if (this.skipEvent(detail))
285 return; 285 return;
286 286
287 if (this.lastPressedKey) 287 if (this.lastPressedKey)
288 this.lastPressedKey.classList.remove('active'); 288 this.lastPressedKey.classList.remove('active');
289 this.lastPressedKey = event.target; 289 this.lastPressedKey = event.target;
290 this.lastPressedKey.classList.add('active'); 290 this.lastPressedKey.classList.add('active');
291 repeatKey.cancel(); 291 repeatKey.cancel();
292
293 var char = detail.char;
294 switch(char) {
295 case 'Shift':
296 // Removes caps-lock if caps-locked.
297 if(this.classList.contains('caps-locked')) {
298 this.classList.remove('caps-locked');
299 }
300 break;
301 default:
302 break;
303 }
304
305 // A transition key was pressed, immediately move to new keyset.
292 var toKeyset = detail.toKeyset; 306 var toKeyset = detail.toKeyset;
293 if (toKeyset) { 307 if (toKeyset) {
294 this.keyset = toKeyset; 308 this.keyset = toKeyset;
295 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = 309 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
296 detail.nextKeyset; 310 detail.nextKeyset;
297 return; 311 return;
298 } 312 }
299 313
300 if (detail.repeat) { 314 if (detail.repeat) {
301 this.keyTyped(detail); 315 this.keyTyped(detail);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (swipeInProgress) 407 if (swipeInProgress)
394 return; 408 return;
395 this.lastPressedKey.classList.remove('active'); 409 this.lastPressedKey.classList.remove('active');
396 if (this.lastPressedKey != event.target) 410 if (this.lastPressedKey != event.target)
397 return; 411 return;
398 if (repeatKey.key == event.target) { 412 if (repeatKey.key == event.target) {
399 repeatKey.cancel(); 413 repeatKey.cancel();
400 return; 414 return;
401 } 415 }
402 var toKeysetId = detail.toKeyset; 416 var toKeysetId = detail.toKeyset;
403 // Keyset transition key. 417 // Keyset transition key. This is needed to transition from upper
418 // to lower case when we are not in caps mode.
404 if (toKeysetId) { 419 if (toKeysetId) {
405 this.keyset = toKeysetId; 420 this.keyset = toKeysetId;
406 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = 421 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
407 detail.nextKeyset; 422 detail.nextKeyset;
408 } 423 }
409 var toLayoutId = detail.toLayout; 424 var toLayoutId = detail.toLayout;
410 // Layout transition key. 425 // Layout transition key.
411 if (toLayoutId) 426 if (toLayoutId)
412 this.layout = toLayoutId; 427 this.layout = toLayoutId;
413 var char = detail.char; 428 var char = detail.char;
414 if (enterUpperOnSpace) { 429 if (enterUpperOnSpace) {
415 enterUpperOnSpace = false; 430 enterUpperOnSpace = false;
416 if (char == ' ') 431 if (char == ' ')
417 this.keyset = 'upper'; 432 this.keyset = 'upper';
418 } 433 }
419 switch(char) { 434 switch(char) {
420 case 'Invalid': 435 case 'Invalid':
421 swipeStatus.swipeFlags = 0; 436 swipeStatus.swipeFlags = 0;
422 return; 437 return;
423 case 'Shift': 438 case 'Shift':
424 swipeStatus.swipeFlags = 0; 439 swipeStatus.swipeFlags = 0;
425 // We have reverted to lower case.
426 if(this.classList.contains('caps-locked'))
427 this.classList.remove('caps-locked');
428 return; 440 return;
429 case 'Microphone': 441 case 'Microphone':
430 this.voiceInput_.onDown(); 442 this.voiceInput_.onDown();
431 return; 443 return;
432 case '.': 444 case '.':
433 case '?': 445 case '?':
434 case '!': 446 case '!':
435 enterUpperOnSpace = true; 447 enterUpperOnSpace = true;
436 break; 448 break;
437 default: 449 default:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 559 }
548 } 560 }
549 if (keysetsLoaded) 561 if (keysetsLoaded)
550 console.error('No default keyset found for ' + this.layout); 562 console.error('No default keyset found for ' + this.layout);
551 return false; 563 return false;
552 } 564 }
553 }); 565 });
554 </script> 566 </script>
555 </polymer-element> 567 </polymer-element>
556 568
OLDNEW
« no previous file with comments | « ui/keyboard/resources/elements/kb-key.html ('k') | ui/keyboard/resources/layouts/dvorak.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698