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

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

Issue 16972006: Insert text directly from the virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix include Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/keyboard/resources/api_adapter.js ('k') | ui/keyboard/resources/keysets.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 (c) 2013 The Chromium Authors. All rights reserved. 2 -- Copyright (c) 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 <element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" 7 <element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp"
8 on-key-down="keyDown" attributes="keyset rows"> 8 on-key-down="keyDown" attributes="keyset rows">
9 <template> 9 <template>
10 <content select="#{{keyset}}"></content> 10 <content select="#{{keyset}}"></content>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 * @param {Object} detail The detail of pressed kb-key. 88 * @param {Object} detail The detail of pressed kb-key.
89 */ 89 */
90 keyDown: function(event, detail) { 90 keyDown: function(event, detail) {
91 var toKeyset = detail.toKeyset; 91 var toKeyset = detail.toKeyset;
92 if (this.lastPressedKey) 92 if (this.lastPressedKey)
93 this.lastPressedKey.classList.remove('active'); 93 this.lastPressedKey.classList.remove('active');
94 this.lastPressedKey = event.target; 94 this.lastPressedKey = event.target;
95 this.lastPressedKey.classList.add('active'); 95 this.lastPressedKey.classList.add('active');
96 repeatKey.cancel(); 96 repeatKey.cancel();
97 if (detail.repeat) { 97 if (detail.repeat) {
98 sendKey(detail.char); 98 insertText(detail.char);
99 repeatKey.key = this.lastPressedKey; 99 repeatKey.key = this.lastPressedKey;
100 repeatKey.timer = setTimeout(function() { 100 repeatKey.timer = setTimeout(function() {
101 repeatKey.timer = undefined; 101 repeatKey.timer = undefined;
102 repeatKey.interval = setInterval(function() { 102 repeatKey.interval = setInterval(function() {
103 sendKey(detail.char); 103 insertText(detail.char);
104 }, REPEAT_INTERVAL_MSEC); 104 }, REPEAT_INTERVAL_MSEC);
105 }, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC)); 105 }, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC));
106 } 106 }
107 }, 107 },
108 108
109 /** 109 /**
110 * Handles key-up event that is sent by kb-key. 110 * Handles key-up event that is sent by kb-key.
111 * @param {CustomEvent} event The key-up event dispatched by kb-key. 111 * @param {CustomEvent} event The key-up event dispatched by kb-key.
112 * @param {Object} detail The detail of pressed kb-key. 112 * @param {Object} detail The detail of pressed kb-key.
113 */ 113 */
114 keyUp: function(event, detail) { 114 keyUp: function(event, detail) {
115 this.lastPressedKey.classList.remove('active'); 115 this.lastPressedKey.classList.remove('active');
116 if (this.lastPressedKey != event.target) 116 if (this.lastPressedKey != event.target)
117 return; 117 return;
118 if (repeatKey.key == event.target) { 118 if (repeatKey.key == event.target) {
119 repeatKey.cancel(); 119 repeatKey.cancel();
120 return; 120 return;
121 } 121 }
122 var toKeyset = detail.toKeyset; 122 var toKeyset = detail.toKeyset;
123 // Keyset transtion key. 123 // Keyset transtion key.
124 if (toKeyset) { 124 if (toKeyset) {
125 this.keyset = toKeyset; 125 this.keyset = toKeyset;
126 } 126 }
127 var char = detail.char; 127 var char = detail.char;
128 if (enterUpperOnSpace) { 128 if (enterUpperOnSpace) {
129 enterUpperOnSpace = false; 129 enterUpperOnSpace = false;
130 if (char == 'Spacebar') 130 if (char == ' ')
131 this.keyset = 'upper'; 131 this.keyset = 'upper';
132 } 132 }
133 switch(char) { 133 switch(char) {
134 case 'Invalid': 134 case 'Invalid':
135 return; 135 return;
136 case 'Mic': 136 case 'Mic':
137 this.voiceInput_.onDown(); 137 this.voiceInput_.onDown();
138 return; 138 return;
139 case '.': 139 case '.':
140 case '?': 140 case '?':
141 case '!': 141 case '!':
142 enterUpperOnSpace = true; 142 enterUpperOnSpace = true;
143 break; 143 break;
144 case 'Tab':
145 case 'Spacebar':
146 case 'Enter':
147 sendKey(char);
148 return;
149 default: 144 default:
150 break; 145 break;
151 } 146 }
152 for (var i = 0; i < char.length; i++) { 147 insertText(char);
153 sendKey(char.charAt(i));
154 }
155 } 148 }
156 }); 149 });
157 </script> 150 </script>
158 </element> 151 </element>
159 152
OLDNEW
« no previous file with comments | « ui/keyboard/resources/api_adapter.js ('k') | ui/keyboard/resources/keysets.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698