Commit 3eee7359 authored by campaign's avatar campaign

修复光标问题

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