Commit 3eee7359 authored by campaign's avatar campaign

修复光标问题

parent dffc771b
......@@ -25,7 +25,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.keyboardEvents.call(me, new MinderEvent(e.type == 'keyup' ? 'beforekeyup' : e.type, e));
});
}
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);'); //
utils.addCssRule('km_receiver_css', ' .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;'); //clip:rect(1em 1em 1em 1em);
this.km.on('inputready.beforekeyup inputready.beforekeydown textedit.beforekeyup textedit.beforekeydown textedit.keypress textedit.paste', utils.proxy(this.keyboardEvents, this));
this.timer = null;
this.index = 0;
......@@ -200,6 +200,10 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.setStatus('normal');
return;
}
if(!orgEvt.shiftKey){
this.selection.baseOffset =
this.selection.currentEndOffset = null;
}
break;
// case keymap.Shift:
case keymap.Control:
......@@ -215,9 +219,7 @@ Minder.Receiver = kity.createClass('Receiver', {
}
//针对按住shift+方向键进行处理
if(orgEvt.shiftKey && keymap.direction[keyCode] && this.selection.isShow()){
if(this.selection.baseOffset === null){
this.selection.baseOffset = this.selection.startOffset;
this.selection.currentEndOffset = this.selection.endOffset;
}
......@@ -292,9 +294,21 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if(browser.ipad){
if(this.selection.isShow()){
this.clear();
this.km.setStatus('inputready');
clearTimeout(me.inputTextTimer);
e.preventDefault();
}else{
this.km.setStatus('normal');
this.km.fire('contentchange');
}
restoreTextContent();
return;
}
if (keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)) {
setTextToContainer();
}
if (this.keydownNode === this.minderNode) {
this.rollbackStatus();
......@@ -305,7 +319,6 @@ Minder.Receiver = kity.createClass('Receiver', {
case keymap.Del:
case keymap.Backspace:
case keymap.Spacebar:
setTextToContainer();
return;
}
......@@ -362,7 +375,7 @@ Minder.Receiver = kity.createClass('Receiver', {
setContainerStyle: function() {
var textShapeBox = this.getBaseOffset('screen');
this.container.style.cssText = ';left:' + (browser.ipad ? '-' : '') +
textShapeBox.x + 'px;top:' + (textShapeBox.y) +
textShapeBox.x + 'px;top:' + (textShapeBox.y + 20) +
'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
return this;
......@@ -450,7 +463,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.selection.setStartOffset(i);
}
if (offset.x <= v.x + v.width / 2) {
me.selection.collapse();
me.selection.collapse(true);
} else {
me.selection.setEndOffset(i + ((me.selection.endOffset > i ||
dir == 1) && i != me.textData.length - 1 ? 1 : 0));
......
......@@ -19,25 +19,22 @@ Minder.Selection = kity.createClass( 'Selection', {
setColor:function(color){
this.fill(color);
},
collapse : function(toEnd){
collapse : function(toStart){
this.setOpacity(1);
this.width = 2;
this.collapsed = true;
if(toEnd){
this.startOffset = this.endOffset;
}else{
if(toStart){
this.endOffset = this.startOffset;
}else{
this.startOffset = this.endOffset;
}
return this;
},
setStartOffset:function(offset){
this.startOffset = offset;
var tmpOffset = this.startOffset;
if(this.startOffset > this.endOffset){
this.startOffset = this.endOffset;
this.endOffset = tmpOffset;
}else if(this.startOffset == this.endOffset){
this.collapse();
if(this.startOffset >= this.endOffset){
this.collapse(true);
return this;
}
this.collapsed = false;
......@@ -46,16 +43,12 @@ Minder.Selection = kity.createClass( 'Selection', {
},
setEndOffset:function(offset){
this.endOffset = offset;
var tmpOffset = this.endOffset;
if(this.endOffset < this.startOffset){
this.endOffset = this.startOffset;
this.startOffset = tmpOffset;
}else if(this.startOffset == this.endOffset){
this.collapse();
if(this.endOffset <= this.startOffset){
this.startOffset = offset;
this.collapse(true);
return this;
}
this.collapsed = false;
// this.stroke('none',0);
this.setOpacity(0.5);
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