Commit 58786c2a authored by rsadam@chromium.org's avatar rsadam@chromium.org

Added persistent capitalization to the Virtual Keyboard.

BUG=280147

Review URL: https://chromiumcodereview.appspot.com/23534021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220628 0039d316-1c4b-4281-b951-d872f2087c98
parent 04123796
...@@ -49,6 +49,20 @@ ...@@ -49,6 +49,20 @@
*/ */
var DBL_INTERVAL_MSEC = 300; var DBL_INTERVAL_MSEC = 300;
/**
* The index of the name of the keyset when searching for all keysets.
* @const
* @type {number}
*/
var REGEX_KEYSET_INDEX = 1;
/**
* The integer number of matches when searching for keysets.
* @const
* @type {number}
*/
var REGEX_MATCH_COUNT = 2;
/** /**
* The boolean to decide if keyboard should transit to upper case keyset * The boolean to decide if keyboard should transit to upper case keyset
* when spacebar is pressed. If a closing punctuation is followed by a * when spacebar is pressed. If a closing punctuation is followed by a
...@@ -186,9 +200,10 @@ ...@@ -186,9 +200,10 @@
var keysetId = '#' + this.layout + '-' + this.keyset; var keysetId = '#' + this.layout + '-' + this.keyset;
var keyset = this.querySelector(keysetId); var keyset = this.querySelector(keysetId);
// Unlocks the keyboard if the current keyset is not lockable. // If capslock is enabled and capsLockTo is not null,
if (!keyset.getAttribute('lockable')) // redirect to keyset specified by capsLockTo.
this.classList.remove('locked'); if (this.classList.contains('caps-locked') && keyset.capsLocksTo)
this.keyset = keyset.capsLocksTo;
}, },
...@@ -348,9 +363,7 @@ ...@@ -348,9 +363,7 @@
keyset.nextKeyset = this.dblTimer_.nextKeyset; keyset.nextKeyset = this.dblTimer_.nextKeyset;
clearTimeout(this.dblTimer_); clearTimeout(this.dblTimer_);
// Checks if shift is capitalized. this.classList.add('caps-locked');
if (keyset.getAttribute('lockable'))
this.classList.add('locked');
this.dblDetail_ = null; this.dblDetail_ = null;
} }
...@@ -385,17 +398,17 @@ ...@@ -385,17 +398,17 @@
repeatKey.cancel(); repeatKey.cancel();
return; return;
} }
var toKeyset = detail.toKeyset; var toKeysetId = detail.toKeyset;
// Keyset transition key. // Keyset transition key.
if (toKeyset) { if (toKeysetId) {
this.keyset = toKeyset; this.keyset = toKeysetId;
this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
detail.nextKeyset; detail.nextKeyset;
} }
var toLayout = detail.toLayout; var toLayoutId = detail.toLayout;
// Layout transition key. // Layout transition key.
if (toLayout) if (toLayoutId)
this.layout = toLayout; this.layout = toLayoutId;
var char = detail.char; var char = detail.char;
if (enterUpperOnSpace) { if (enterUpperOnSpace) {
enterUpperOnSpace = false; enterUpperOnSpace = false;
...@@ -404,8 +417,13 @@ ...@@ -404,8 +417,13 @@
} }
switch(char) { switch(char) {
case 'Invalid': case 'Invalid':
swipeStatus.swipeFlags = 0;
return;
case 'Shift': case 'Shift':
swipeStatus.swipeFlags = 0; swipeStatus.swipeFlags = 0;
// We have reverted to lower case.
if(this.classList.contains('caps-locked'))
this.classList.remove('caps-locked');
return; return;
case 'Microphone': case 'Microphone':
this.voiceInput_.onDown(); this.voiceInput_.onDown();
...@@ -438,7 +456,7 @@ ...@@ -438,7 +456,7 @@
detail.nextKeyset; detail.nextKeyset;
// Locks the keyset before removing active to prevent flicker. // Locks the keyset before removing active to prevent flicker.
this.classList.add('locked'); this.classList.add('caps-locked');
// Makes last pressed key inactive if transit to a new keyset on long // Makes last pressed key inactive if transit to a new keyset on long
// press. // press.
this.lastPressedKey.classList.remove('active'); this.lastPressedKey.classList.remove('active');
...@@ -474,10 +492,10 @@ ...@@ -474,10 +492,10 @@
var keysetsLoaded = false; var keysetsLoaded = false;
for (var i = 0; i < keysets.length; i++) { for (var i = 0; i < keysets.length; i++) {
var matches = keysets[i].id.match(regex); var matches = keysets[i].id.match(regex);
if (matches && matches.length == 2) { if (matches && matches.length == REGEX_MATCH_COUNT) {
keysetsLoaded = true; keysetsLoaded = true;
if (keysets[i].isDefault) { if (keysets[i].isDefault) {
this.keyset = matches[1]; this.keyset = matches[REGEX_KEYSET_INDEX];
return true; return true;
} }
} }
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
-- found in the LICENSE file. -- found in the LICENSE file.
--> -->
<polymer-element name="kb-keyset" attributes="nextKeyset isDefault" <polymer-element name="kb-keyset" attributes="nextKeyset isDefault
on-key-up="keyUp" on-key-longpress="keyLongpress"> capsLocksTo capsLockable" on-key-up="keyUp"
on-key-longpress="keyLongpress">
<template> <template>
<style> <style>
@host { @host {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<link id="spacebar-row" rel="import" href="spacebar-row.html"> <link id="spacebar-row" rel="import" href="spacebar-row.html">
<template> <template>
<kb-keyset id="dvorak-upper" lockable="true"> <kb-keyset id="dvorak-upper" capsLockable=true>
<kb-row> <kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key> <kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="&quot;,.PYFGCRL" superscripts="1234567890"></kb-key-sequence> <kb-key-sequence keys="&quot;,.PYFGCRL" superscripts="1234567890"></kb-key-sequence>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</kb-altkey-container> </kb-altkey-container>
</kb-keyset> </kb-keyset>
<kb-keyset id="dvorak-lower" isDefault=true> <kb-keyset id="dvorak-lower" capsLocksTo="upper" isDefault=true>
<kb-row> <kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key> <kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="&quot;,.pyfgcrl" superscripts="1234567890"></kb-key-sequence> <kb-key-sequence keys="&quot;,.pyfgcrl" superscripts="1234567890"></kb-key-sequence>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<link id="spacebar-row" rel="import" href="spacebar-row.html"> <link id="spacebar-row" rel="import" href="spacebar-row.html">
<template> <template>
<kb-keyset id="qwerty-upper" lockable="true"> <kb-keyset id="qwerty-upper" capsLockable=true>
<kb-row> <kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key> <kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="QWERTYUIOP" superscripts="1234567890"></kb-key-sequence> <kb-key-sequence keys="QWERTYUIOP" superscripts="1234567890"></kb-key-sequence>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</kb-altkey-container> </kb-altkey-container>
</kb-keyset> </kb-keyset>
<kb-keyset id="qwerty-lower" isDefault=true> <kb-keyset id="qwerty-lower" capsLocksTo="upper" isDefault=true>
<kb-row> <kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key> <kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="qwertyuiop" superscripts="1234567890"></kb-key-sequence> <kb-key-sequence keys="qwertyuiop" superscripts="1234567890"></kb-key-sequence>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
--> -->
<template> <template>
<kb-keyset id="qwerty-upper" lockable="true"> <kb-keyset id="qwerty-upper" capsLockable=true>
<kb-row class="top"> <kb-row class="top">
<kb-key>Q</kb-key><kb-key>W</kb-key><kb-key>E</kb-key><kb-key>R</kb-key> <kb-key>Q</kb-key><kb-key>W</kb-key><kb-key>E</kb-key><kb-key>R</kb-key>
<kb-key>T</kb-key><kb-key>Y</kb-key><kb-key>U</kb-key> <kb-key>T</kb-key><kb-key>Y</kb-key><kb-key>U</kb-key>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</kb-altkey-container> </kb-altkey-container>
</kb-keyset> </kb-keyset>
<kb-keyset id="qwerty-lower" isDefault=true> <kb-keyset id="qwerty-lower" capsLocksTo="upper" isDefault=true>
<kb-row class="top"> <kb-row class="top">
<kb-key>q</kb-key><kb-key>w</kb-key><kb-key>e</kb-key><kb-key>r</kb-key> <kb-key>q</kb-key><kb-key>w</kb-key><kb-key>e</kb-key><kb-key>r</kb-key>
<kb-key>t</kb-key><kb-key>y</kb-key><kb-key>u</kb-key> <kb-key>t</kb-key><kb-key>y</kb-key><kb-key>u</kb-key>
......
...@@ -72,7 +72,7 @@ kb-key::x-superscript[inverted] { ...@@ -72,7 +72,7 @@ kb-key::x-superscript[inverted] {
* Controls whether the shift key should be highlighted or not. * Controls whether the shift key should be highlighted or not.
* Only highlights if we are in a lockable keyboard which is not locked. * Only highlights if we are in a lockable keyboard which is not locked.
*/ */
kb-keyboard:not(.locked) kb-keyset[lockable] kb-shift-key { kb-keyboard:not(.caps-locked) kb-keyset[capsLockable] kb-shift-key {
color: lightblue; color: lightblue;
} }
...@@ -95,7 +95,7 @@ kb-altkey::x-key { ...@@ -95,7 +95,7 @@ kb-altkey::x-key {
text-align: center; text-align: center;
} }
.locked kb-shift-key, .caps-locked kb-shift-key,
.active { .active {
background-color: #848490 !important; background-color: #848490 !important;
border-top: 2px solid #A9A9AF !important; border-top: 2px solid #A9A9AF !important;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment