mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Prevent TextBox from blurring unless explicity by user.
This commit is contained in:
parent
d0b6e2a63d
commit
c807dd29e4
@ -172,7 +172,9 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
"keyup input" : "handleChanging",
|
||||
"paste input" : "handleChanging",
|
||||
"cut input" : "handleChanging",
|
||||
"keypress input" : "handleKeypress"
|
||||
"keypress input" : "handleKeypress",
|
||||
"blur input" : "handleBlur",
|
||||
"focusout input" : "handleFocusOut"
|
||||
},
|
||||
|
||||
handleChanging: function(e) {
|
||||
@ -188,6 +190,31 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
// Handles text submition
|
||||
if (e.keyCode == 13) { // Return key
|
||||
this.send({event: 'submit'});
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
handleBlur: function(e) {
|
||||
// Prevent a blur from firing if the blur was not user intended.
|
||||
// This is a workaround for the return-key focus loss bug.
|
||||
// TODO: Is the original bug actually a fault of the keyboard
|
||||
// manager?
|
||||
if (e.relatedTarget === null) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
handleFocusOut: function(e) {
|
||||
// Prevent a blur from firing if the blur was not user intended.
|
||||
// This is a workaround for the return-key focus loss bug.
|
||||
if (e.relatedTarget === null) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user