summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 01:02:08 +0000
committerrsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 01:02:08 +0000
commit2a7fd420d50aec8f5aaf590c721453dac0bd8994 (patch)
treef265a35872aa73dd198af56e6fa06867cee03f6b /ui
parentc87b65cb6a13e04c1ac8a020f9ea80db26a2430e (diff)
downloadchromium_src-2a7fd420d50aec8f5aaf590c721453dac0bd8994.zip
chromium_src-2a7fd420d50aec8f5aaf590c721453dac0bd8994.tar.gz
chromium_src-2a7fd420d50aec8f5aaf590c721453dac0bd8994.tar.bz2
Enables chording with the control and alt keys.
Note that there is an edge case where we start chording with control (or alt) before continuing chording with shift. This will not work. Added a TODO to fix that; but it isn't an immediate priority. BUG=312336 Review URL: https://codereview.chromium.org/49243002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231967 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/keyboard/resources/elements/kb-key-base.html27
-rw-r--r--ui/keyboard/resources/elements/kb-keyboard.html4
-rw-r--r--ui/keyboard/resources/elements/kb-modifier-key.html35
3 files changed, 55 insertions, 11 deletions
diff --git a/ui/keyboard/resources/elements/kb-key-base.html b/ui/keyboard/resources/elements/kb-key-base.html
index b14f415..f522370 100644
--- a/ui/keyboard/resources/elements/kb-key-base.html
+++ b/ui/keyboard/resources/elements/kb-key-base.html
@@ -121,7 +121,7 @@
clearTimeout(this.longPressTimer);
},
up: function(event) {
- this.autoRelease();
+ this.generateKeyup();
},
/**
@@ -130,15 +130,7 @@
* released yet.
*/
autoRelease: function() {
- if (this.pointerId === undefined)
- return;
-
- // Invalidates the pointerId so the subsequent pointerup event is a
- // noop.
- this.pointerId = undefined;
- clearTimeout(this.longPressTimer);
- var detail = this.populateDetails('up');
- this.fire('key-up', detail);
+ this.generateKeyup();
},
/**
@@ -151,6 +143,21 @@
},
/**
+ * Populates details for this key, and then fires a key-up event.
+ */
+ generateKeyup: function() {
+ if (this.pointerId === undefined)
+ return;
+
+ // Invalidates the pointerId so the subsequent pointerup event is a
+ // noop.
+ this.pointerId = undefined;
+ clearTimeout(this.longPressTimer);
+ var detail = this.populateDetails('up');
+ this.fire('key-up', detail);
+ },
+
+ /**
* Character value associated with the key. Typically, the value is a
* single character, but may be multi-character in cases like a ".com"
* button.
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html
index aa72c75..c7a3988 100644
--- a/ui/keyboard/resources/elements/kb-keyboard.html
+++ b/ui/keyboard/resources/elements/kb-keyboard.html
@@ -372,6 +372,10 @@
// Notify shift key.
if (this.shift)
this.shift.onNonControlKeyDown();
+ if (this.ctrl)
+ this.ctrl.onNonControlKeyDown();
+ if (this.alt)
+ this.alt.onNonControlKeyDown();
break;
}
if(this.changeKeyset(detail))
diff --git a/ui/keyboard/resources/elements/kb-modifier-key.html b/ui/keyboard/resources/elements/kb-modifier-key.html
index ebe9cf7..572ae15 100644
--- a/ui/keyboard/resources/elements/kb-modifier-key.html
+++ b/ui/keyboard/resources/elements/kb-modifier-key.html
@@ -4,7 +4,8 @@
-- found in the LICENSE file.
-->
-<polymer-element name="kb-modifier-key" class="unlocked dark" extends="kb-key">
+<polymer-element name="kb-modifier-key" class="unlocked dark" extends="kb-key"
+ on-pointerout="out">
<script>
(function () {
@@ -17,6 +18,7 @@
PRESSED: "pressed", // Key-down.
UNLOCKED: "unlocked", // Default state.
TAPPED: "tapped", // Key-down followed by key-up.
+ CHORDING: "chording", // Chording mode.
};
/**
@@ -45,6 +47,7 @@
this.state = KEY_STATES.UNLOCKED;
break;
case KEY_STATES.PRESSED:
+ case KEY_STATES.CHORDING:
// We pressed another key at the same time,
// so ignore second press.
return;
@@ -64,6 +67,18 @@
},
/**
+ * Notifies key that a non-control keyed down.
+ * A control key is defined as one of shift, control or alt.
+ */
+ onNonControlKeyDown: function() {
+ switch(this.state) {
+ case (KEY_STATES.PRESSED):
+ this.state = KEY_STATES.CHORDING;
+ break;
+ }
+ },
+
+ /**
* Notifies key that a non-control keyed was typed.
* A control key is defined as one of shift, control or alt.
*/
@@ -75,6 +90,24 @@
}
},
+ /**
+ * Called on a pointer-out event. Ends chording.
+ * @param {event} event The pointer-out event.
+ */
+ out: function(event) {
+ // TODO(rsadam): Add chording event so that we don't reset
+ // when shift-chording.
+ if (this.state == KEY_STATES.CHORDING) {
+ this.state = KEY_STATES.UNLOCKED;
+ }
+ },
+
+ /*
+ * Overrides the autoRelease function to enable chording.
+ */
+ autoRelease: function() {
+ },
+
populateDetails: function(caller) {
var detail = this.super([caller]);
if (this.state != KEY_STATES.UNLOCKED)