Commit edaec00e authored by campaign's avatar campaign

修复光标问题

parent 8e2e9fbc
...@@ -99,7 +99,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -99,7 +99,7 @@ Minder.Receiver = kity.createClass('Receiver', {
var orgEvt = e.originEvent; var orgEvt = e.originEvent;
var keyCode = orgEvt.keyCode; var keyCode = orgEvt.keyCode;
function setTextToContainer() { function setTextToContainer(keyCode) {
clearTimeout(me.timer); clearTimeout(me.timer);
if (!me.range.hasNativeRange()) { if (!me.range.hasNativeRange()) {
return; return;
...@@ -131,10 +131,15 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -131,10 +131,15 @@ Minder.Receiver = kity.createClass('Receiver', {
me.setContainerStyle(); me.setContainerStyle();
me.minderNode.getRenderContainer().bringTop(); me.minderNode.getRenderContainer().bringTop();
me.minderNode.render(); me.minderNode.render();
clearTimeout(me.inputTextTimer); //移动光标不做layout
me.inputTextTimer = setTimeout(function(){ if(!keymap.direction[keyCode]){
me.km.layout(300); clearTimeout(me.inputTextTimer);
},250);
me.inputTextTimer = setTimeout(function(){
me.km.layout(300);
},250);
}
me.textShape = me.minderNode.getRenderer('TextRenderer').getRenderShape(); me.textShape = me.minderNode.getRenderer('TextRenderer').getRenderShape();
if (text.length === 0) { if (text.length === 0) {
...@@ -293,19 +298,19 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -293,19 +298,19 @@ Minder.Receiver = kity.createClass('Receiver', {
var index = me.container.textContent.indexOf('$$_kityminder_bookmark_$$'); var index = me.container.textContent.indexOf('$$_kityminder_bookmark_$$');
me.container.textContent = me.container.textContent.replace('$$_kityminder_bookmark_$$', ''); me.container.textContent = me.container.textContent.replace('$$_kityminder_bookmark_$$', '');
me.range.setStart(me.container.firstChild, index).collapse(true).select(); me.range.setStart(me.container.firstChild, index).collapse(true).select();
setTextToContainer(); setTextToContainer(keyCode);
}, 100); }, 100);
} }
//剪切 //剪切
if (keyCode == keymap.x) { if (keyCode == keymap.x) {
setTimeout(function() { setTimeout(function() {
setTextToContainer(); setTextToContainer(keyCode);
}, 100); }, 100);
} }
return; return;
} }
setTimeout(function() { setTimeout(function() {
setTextToContainer(); setTextToContainer(keyCode);
}); });
break; break;
...@@ -328,7 +333,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -328,7 +333,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return; return;
} }
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) { if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
setTextToContainer(); setTextToContainer(keyCode);
} }
if (this.keydownNode === this.minderNode) { if (this.keydownNode === this.minderNode) {
this.rollbackStatus(); this.rollbackStatus();
...@@ -339,14 +344,14 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -339,14 +344,14 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del: case keymap.Del:
case keymap.Backspace: case keymap.Backspace:
case keymap.Spacebar: case keymap.Spacebar:
setTextToContainer(); setTextToContainer(keyCode);
return; return;
} }
if (this.isTypeText) { if (this.isTypeText) {
setTextToContainer(); setTextToContainer(keyCode);
} }
if (browser.mac && browser.gecko) if (browser.mac && browser.gecko)
setTextToContainer(); setTextToContainer(keyCode);
return true; return true;
} }
...@@ -514,9 +519,11 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -514,9 +519,11 @@ Minder.Receiver = kity.createClass('Receiver', {
width = 0; width = 0;
if (this.selection.collapsed) { if (this.selection.collapsed) {
if(startOffset === undefined){ if(startOffset === undefined){
var tmpOffset = this.textData[this.textData.length - 1]; var tmpOffset = this.textData[this.textData.length - 1];
tmpOffset = utils.clone(tmpOffset);
tmpOffset.x = tmpOffset.x + tmpOffset.width; tmpOffset.x = tmpOffset.x + tmpOffset.width;
startOffset = tmpOffset startOffset = tmpOffset;
} }
this.selection.updateShow(startOffset, 2); this.selection.updateShow(startOffset, 2);
return this; return this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment