add support for contextmenu
This commit is contained in:
parent
be2e78616e
commit
27a95f634d
3 changed files with 30 additions and 6 deletions
|
|
@ -74,7 +74,7 @@
|
|||
}
|
||||
|
||||
.ace_editor textarea {
|
||||
position: "absolute";
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
opacity: 0;
|
||||
width: 10px;
|
||||
|
|
|
|||
|
|
@ -281,11 +281,11 @@ var Editor =function(renderer, session) {
|
|||
|
||||
this.onCursorChange = function(e) {
|
||||
this.$highlightBrackets();
|
||||
|
||||
|
||||
// move text input over the cursor
|
||||
// this is required for iOS and IME
|
||||
this.renderer.moveTextAreaToCursor(this.textInput.getElement());
|
||||
|
||||
|
||||
this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite);
|
||||
|
||||
if (!this.$blockScrolling && (!e || !e.blockScrolling)) {
|
||||
|
|
@ -357,10 +357,16 @@ var Editor =function(renderer, session) {
|
|||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||
pos.row = Math.max(0, Math.min(pos.row, this.session.getLength()-1));
|
||||
|
||||
if (event.getButton(e) != 0) {
|
||||
if (this.selection.isEmpty()) {
|
||||
var button = event.getButton(e)
|
||||
if (button != 0) {
|
||||
var isEmpty = this.selection.isEmpty()
|
||||
if (isEmpty) {
|
||||
this.moveCursorToPosition(pos);
|
||||
}
|
||||
if(button == 2) {
|
||||
this.textInput.onContextMenu({x: pageX, y: pageY}, isEmpty);
|
||||
event.capture(this.container, function(){}, this.textInput.onContextMenuClose);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,10 +184,28 @@ var TextInput = function(parentNode, host) {
|
|||
this.blur = function() {
|
||||
text.blur();
|
||||
};
|
||||
|
||||
|
||||
this.getElement = function() {
|
||||
return text;
|
||||
};
|
||||
|
||||
this.onContextMenu = function(mousePos, isEmpty){
|
||||
if(mousePos){
|
||||
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 () {
|
||||
sendText();
|
||||
}, 0);
|
||||
text.style.position = '';
|
||||
text.style.zIndex = '';
|
||||
}
|
||||
};
|
||||
|
||||
exports.TextInput = TextInput;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue