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.setReadOnly = function(readOnly) {
this.$readOnly = 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, "keyup", onCompositionUpdate);
event.addListener(text, "compositionend", onCompositionEnd); event.addListener(text, "compositionend", onCompositionEnd);
// CONTEXTMENU
this.getElement = function() { this.getElement = function() {
return text; return text;
}; };
this.setReadOnly = function(readOnly) {
text.readOnly = readOnly;
};
this.onContextMenu = function(e) { this.onContextMenu = function(e) {
if (!tempStyle) if (!tempStyle)
tempStyle = text.style.cssText; tempStyle = text.style.cssText;

View file

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