Merge remote branch 'nightwing/contextMenu'
This commit is contained in:
commit
468df4cd51
2 changed files with 32 additions and 3 deletions
|
|
@ -357,10 +357,16 @@ var Editor =function(renderer, session) {
|
||||||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||||
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
||||||
|
|
||||||
if (event.getButton(e) != 0) {
|
var button = event.getButton(e)
|
||||||
if (this.selection.isEmpty()) {
|
if (button != 0) {
|
||||||
|
var isEmpty = this.selection.isEmpty()
|
||||||
|
if (isEmpty) {
|
||||||
this.moveCursorToPosition(pos);
|
this.moveCursorToPosition(pos);
|
||||||
}
|
}
|
||||||
|
if(button == 2) {
|
||||||
|
this.textInput.onContextMenu({x: pageX, y: pageY}, isEmpty);
|
||||||
|
event.capture(this.container, function(){}, this.textInput.onContextMenuClose);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
var inCompostion = false;
|
var inCompostion = false;
|
||||||
var copied = false;
|
var copied = false;
|
||||||
|
var tempStyle = '';
|
||||||
|
|
||||||
function sendText(valueToSend) {
|
function sendText(valueToSend) {
|
||||||
if (!copied) {
|
if (!copied) {
|
||||||
|
|
@ -184,10 +185,32 @@ var TextInput = function(parentNode, host) {
|
||||||
this.blur = function() {
|
this.blur = function() {
|
||||||
text.blur();
|
text.blur();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getElement = function() {
|
this.getElement = function() {
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onContextMenu = function(mousePos, isEmpty){
|
||||||
|
if (mousePos) {
|
||||||
|
if(!tempStyle)
|
||||||
|
tempStyle = text.style.cssText;
|
||||||
|
text.style.cssText = 'position:fixed; z-index:1000;' +
|
||||||
|
'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;'
|
||||||
|
|
||||||
|
}
|
||||||
|
if (isEmpty)
|
||||||
|
text.value='';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onContextMenuClose = function(){
|
||||||
|
setTimeout(function () {
|
||||||
|
if (tempStyle) {
|
||||||
|
text.style.cssText = tempStyle;
|
||||||
|
tempStyle = '';
|
||||||
|
}
|
||||||
|
sendText();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.TextInput = TextInput;
|
exports.TextInput = TextInput;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue