Fix contextMenu when editor require scrolling

When editor is not at the top of the page (requires scrolling), textarea
right-click context menu will fail to appear.

Use clientX and clientY which returns the relative coordinates instead
of pageX and pageY.
This commit is contained in:
Lee Sing Jie 2011-11-29 21:25:25 +08:00
commit 92d1b7559b
2 changed files with 5 additions and 2 deletions

View file

@ -96,7 +96,7 @@ function DefaultHandlers(editor) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
editor.textInput.onContextMenu({x: pageX, y: pageY}, selectionEmpty);
editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;

View file

@ -51,6 +51,9 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
this.pageX = event.getDocumentX(domEvent);
this.pageY = event.getDocumentY(domEvent);
this.clientX = domEvent.clientX;
this.clientY = domEvent.clientY;
this.$pos = null;
this.$inSelection = null;
@ -130,4 +133,4 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
}).call(MouseEvent.prototype);
});
});