ReadOnly fixes

This commit is contained in:
DanyaPostfactum 2013-01-24 19:54:07 +10:00 committed by nightwing
commit 88a566977b
3 changed files with 14 additions and 3 deletions

View file

@ -1015,6 +1015,8 @@ var Editor = function(renderer, session) {
**/
this.setReadOnly = function(readOnly) {
this.$readOnly = readOnly;
this.textInput.setReadOnly(readOnly);
this.renderer.$cursorLayer.setBlinking(!readOnly);
};
/**

View file

@ -355,11 +355,14 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "keyup", onCompositionUpdate);
event.addListener(text, "compositionend", onCompositionEnd);
// CONTEXTMENU
this.getElement = function() {
return text;
};
this.setReadOnly = function(readOnly) {
text.readOnly = readOnly;
};
this.onContextMenu = function(e) {
if (!tempStyle)
tempStyle = text.style.cssText;

View file

@ -41,6 +41,8 @@ var DragdropHandler = function(mouseHandler) {
var mouseTarget = editor.container;
event.addListener(mouseTarget, "dragenter", function(e) {
if (editor.getReadOnly())
return;
counter++;
if (!dragSelectionMarker) {
range = editor.getSelectionRange();
@ -55,6 +57,8 @@ var DragdropHandler = function(mouseHandler) {
});
event.addListener(mouseTarget, "dragover", function(e) {
if (editor.getReadOnly())
return;
x = e.clientX;
y = e.clientY;
return event.preventDefault(e);
@ -67,10 +71,11 @@ var DragdropHandler = function(mouseHandler) {
};
event.addListener(mouseTarget, "dragleave", function(e) {
if (editor.getReadOnly())
return;
counter--;
if (counter > 0)
return;
console.log(e.type, counter,e.target);
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);
dragSelectionMarker = null;
@ -79,7 +84,8 @@ var DragdropHandler = function(mouseHandler) {
});
event.addListener(mouseTarget, "drop", function(e) {
console.log(e.type, counter,e.target);
if (editor.getReadOnly())
return;
counter = 0;
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);