fix #366 Spacebar/Enter non-functional when "+ br" selector used in Chrome
This commit is contained in:
parent
1a3bbcbfd4
commit
353d6a6f8a
2 changed files with 35 additions and 26 deletions
|
|
@ -65,13 +65,15 @@ var TextInput = function(parentNode, host) {
|
|||
value = value.slice(0, -1);
|
||||
if (value)
|
||||
host.onTextInput(value, !pasted);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
host.onTextInput(value, !pasted);
|
||||
}
|
||||
|
||||
// If editor is no longer focused we quit immediately, since
|
||||
// it means that something else like CLI is in charge now.
|
||||
if (!isFocused()) return false;
|
||||
// it means that something else is in charge now.
|
||||
if (!isFocused())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +86,13 @@ var TextInput = function(parentNode, host) {
|
|||
}
|
||||
|
||||
var onTextInput = function(e) {
|
||||
setTimeout(function () {
|
||||
if (!inCompostion)
|
||||
sendText(e.data);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
var onKeyPress = function(e) {
|
||||
if (useragent.isIE && text.value.charCodeAt(0) > 128) return;
|
||||
setTimeout(function() {
|
||||
if (!inCompostion)
|
||||
|
|
@ -93,10 +102,6 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
var onCompositionStart = function(e) {
|
||||
inCompostion = true;
|
||||
if (!useragent.isIE) {
|
||||
sendText();
|
||||
text.value = "";
|
||||
};
|
||||
host.onCompositionStart();
|
||||
if (!useragent.isGecko) setTimeout(onCompositionUpdate, 0);
|
||||
};
|
||||
|
|
@ -109,14 +114,6 @@ var TextInput = function(parentNode, host) {
|
|||
var onCompositionEnd = function(e) {
|
||||
inCompostion = false;
|
||||
host.onCompositionEnd();
|
||||
if (useragent.isGecko) {
|
||||
sendText();
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
if (!inCompostion)
|
||||
sendText();
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
var onCopy = function(e) {
|
||||
|
|
@ -147,7 +144,6 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
|
||||
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
||||
event.addListener(text, "keypress", onTextInput);
|
||||
if (useragent.isIE) {
|
||||
var keytable = { 13:1, 27:1 };
|
||||
event.addListener(text, "keyup", function (e) {
|
||||
|
|
@ -159,7 +155,23 @@ var TextInput = function(parentNode, host) {
|
|||
inCompostion ? onCompositionUpdate() : onCompositionStart();
|
||||
});
|
||||
};
|
||||
event.addListener(text, "textInput", onTextInput);
|
||||
|
||||
if (text.attachEvent) {
|
||||
// Old IE + Opera
|
||||
event.addListener(text, "propertychange", onKeyPress);
|
||||
}
|
||||
else {
|
||||
if (useragent.isChrome || useragent.isSafari)
|
||||
event.addListener(text, "textInput", onTextInput);
|
||||
else if (useragent.isIE)
|
||||
// IE9
|
||||
event.addListener(text, "textinput", onTextInput);
|
||||
else
|
||||
// All browsers except old IE
|
||||
event.addListener(text, "input", onTextInput);
|
||||
}
|
||||
|
||||
|
||||
event.addListener(text, "paste", function(e) {
|
||||
// Mark that the next input text comes from past.
|
||||
pasted = true;
|
||||
|
|
@ -168,16 +180,13 @@ var TextInput = function(parentNode, host) {
|
|||
if (e.clipboardData && e.clipboardData.getData) {
|
||||
sendText(e.clipboardData.getData("text/plain"));
|
||||
e.preventDefault();
|
||||
} else
|
||||
// If a browser doesn't support any of the things above, use the regular
|
||||
// method to detect the pasted input.
|
||||
{
|
||||
onTextInput();
|
||||
}
|
||||
else {
|
||||
// If a browser doesn't support any of the things above, use the regular
|
||||
// method to detect the pasted input.
|
||||
onKeyPress();
|
||||
}
|
||||
});
|
||||
if (!useragent.isIE) {
|
||||
event.addListener(text, "propertychange", onTextInput);
|
||||
};
|
||||
|
||||
if (useragent.isIE) {
|
||||
event.addListener(text, "beforecopy", function(e) {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit a3c45dda8233ef132b6a5b892cc1e19368c33394
|
||||
Subproject commit 02fb4d858c6c4580d6703c22f7230ff44eade033
|
||||
Loading…
Add table
Add a link
Reference in a new issue