##// END OF EJS Templates
Prevent TextBox from blurring unless explicity by user.
Jonathan Frederic -
Show More
@@ -172,7 +172,9 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
172 "keyup input" : "handleChanging",
172 "keyup input" : "handleChanging",
173 "paste input" : "handleChanging",
173 "paste input" : "handleChanging",
174 "cut input" : "handleChanging",
174 "cut input" : "handleChanging",
175 "keypress input" : "handleKeypress"
175 "keypress input" : "handleKeypress",
176 "blur input" : "handleBlur",
177 "focusout input" : "handleFocusOut"
176 },
178 },
177
179
178 handleChanging: function(e) {
180 handleChanging: function(e) {
@@ -188,6 +190,31 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
188 // Handles text submition
190 // Handles text submition
189 if (e.keyCode == 13) { // Return key
191 if (e.keyCode == 13) { // Return key
190 this.send({event: 'submit'});
192 this.send({event: 'submit'});
193 event.stopPropagation();
194 event.preventDefault();
195 return false;
196 }
197 },
198
199 handleBlur: function(e) {
200 // Prevent a blur from firing if the blur was not user intended.
201 // This is a workaround for the return-key focus loss bug.
202 // TODO: Is the original bug actually a fault of the keyboard
203 // manager?
204 if (e.relatedTarget === null) {
205 event.stopPropagation();
206 event.preventDefault();
207 return false;
208 }
209 },
210
211 handleFocusOut: function(e) {
212 // Prevent a blur from firing if the blur was not user intended.
213 // This is a workaround for the return-key focus loss bug.
214 if (e.relatedTarget === null) {
215 event.stopPropagation();
216 event.preventDefault();
217 return false;
191 }
218 }
192 },
219 },
193 });
220 });
General Comments 0
You need to be logged in to leave comments. Login now