Keyboard events are not being cancelled by default now.

This commit is contained in:
paris
2014-03-24 17:10:18 +00:00
parent 7a6fb27a53
commit 06403fd6c8
+28 -19
View File
@@ -138,6 +138,8 @@ function Terminal(options) {
return new Terminal(arguments[0], arguments[1], arguments[2]); return new Terminal(arguments[0], arguments[1], arguments[2]);
} }
self.cancel = Terminal.cancel;
EventEmitter.call(this); EventEmitter.call(this);
if (typeof options === 'number') { if (typeof options === 'number') {
@@ -395,7 +397,8 @@ Terminal.defaults = {
scrollback: 1000, scrollback: 1000,
screenKeys: false, screenKeys: false,
debug: false, debug: false,
useStyle: false useStyle: false,
cancelEvents: false
// programFeatures: false, // programFeatures: false,
// focusKeys: false, // focusKeys: false,
}; };
@@ -498,7 +501,7 @@ Terminal.bindPaste = function(document) {
} }
// Not necessary. Do it anyway for good measure. // Not necessary. Do it anyway for good measure.
term.element.contentEditable = 'inherit'; term.element.contentEditable = 'inherit';
return cancel(ev); return term.cancel(ev);
}); });
}; };
@@ -1079,7 +1082,7 @@ Terminal.prototype.bindMouse = function() {
//if (self.vt200Mouse && !self.normalMouse) { //if (self.vt200Mouse && !self.normalMouse) {
if (self.vt200Mouse) { if (self.vt200Mouse) {
sendButton({ __proto__: ev, type: 'mouseup' }); sendButton({ __proto__: ev, type: 'mouseup' });
return cancel(ev); return self.cancel(ev);
} }
// bind events // bind events
@@ -1091,11 +1094,11 @@ Terminal.prototype.bindMouse = function() {
sendButton(ev); sendButton(ev);
if (self.normalMouse) off(self.document, 'mousemove', sendMove); if (self.normalMouse) off(self.document, 'mousemove', sendMove);
off(self.document, 'mouseup', up); off(self.document, 'mouseup', up);
return cancel(ev); return self.cancel(ev);
}); });
} }
return cancel(ev); return self.cancel(ev);
}); });
//if (self.normalMouse) { //if (self.normalMouse) {
@@ -1108,7 +1111,7 @@ Terminal.prototype.bindMouse = function() {
|| self.vt300Mouse || self.vt300Mouse
|| self.decLocator) return; || self.decLocator) return;
sendButton(ev); sendButton(ev);
return cancel(ev); return self.cancel(ev);
}); });
// allow mousewheel scrolling in // allow mousewheel scrolling in
@@ -1121,7 +1124,7 @@ Terminal.prototype.bindMouse = function() {
} else { } else {
self.scrollDisp(ev.wheelDeltaY > 0 ? -5 : 5); self.scrollDisp(ev.wheelDeltaY > 0 ? -5 : 5);
} }
return cancel(ev); return self.cancel(ev);
}); });
}; };
@@ -2446,7 +2449,7 @@ Terminal.prototype.keyDown = function(ev) {
} }
if (ev.ctrlKey) { if (ev.ctrlKey) {
this.scrollDisp(-1); this.scrollDisp(-1);
return cancel(ev); return this.cancel(ev);
} else { } else {
key = '\x1b[A'; key = '\x1b[A';
} }
@@ -2459,7 +2462,7 @@ Terminal.prototype.keyDown = function(ev) {
} }
if (ev.ctrlKey) { if (ev.ctrlKey) {
this.scrollDisp(1); this.scrollDisp(1);
return cancel(ev); return this.cancel(ev);
} else { } else {
key = '\x1b[B'; key = '\x1b[B';
} }
@@ -2492,7 +2495,7 @@ Terminal.prototype.keyDown = function(ev) {
case 33: case 33:
if (ev.shiftKey) { if (ev.shiftKey) {
this.scrollDisp(-(this.rows - 1)); this.scrollDisp(-(this.rows - 1));
return cancel(ev); return this.cancel(ev);
} else { } else {
key = '\x1b[5~'; key = '\x1b[5~';
} }
@@ -2501,7 +2504,7 @@ Terminal.prototype.keyDown = function(ev) {
case 34: case 34:
if (ev.shiftKey) { if (ev.shiftKey) {
this.scrollDisp(this.rows - 1); this.scrollDisp(this.rows - 1);
return cancel(ev); return this.cancel(ev);
} else { } else {
key = '\x1b[6~'; key = '\x1b[6~';
} }
@@ -2562,7 +2565,7 @@ Terminal.prototype.keyDown = function(ev) {
if (this.screenKeys) { if (this.screenKeys) {
if (!this.prefixMode && !this.selectMode && ev.keyCode === 65) { if (!this.prefixMode && !this.selectMode && ev.keyCode === 65) {
this.enterPrefix(); this.enterPrefix();
return cancel(ev); return this.cancel(ev);
} }
} }
// Ctrl-V // Ctrl-V
@@ -2612,12 +2615,12 @@ Terminal.prototype.keyDown = function(ev) {
if (this.prefixMode) { if (this.prefixMode) {
this.leavePrefix(); this.leavePrefix();
return cancel(ev); return this.cancel(ev);
} }
if (this.selectMode) { if (this.selectMode) {
this.keySelect(ev, key); this.keySelect(ev, key);
return cancel(ev); return this.cancel(ev);
} }
this.emit('keydown', ev); this.emit('keydown', ev);
@@ -2626,7 +2629,7 @@ Terminal.prototype.keyDown = function(ev) {
this.showCursor(); this.showCursor();
this.handler(key); this.handler(key);
return cancel(ev); return this.cancel(ev);
}; };
Terminal.prototype.setgLevel = function(g) { Terminal.prototype.setgLevel = function(g) {
@@ -2644,7 +2647,7 @@ Terminal.prototype.setgCharset = function(g, charset) {
Terminal.prototype.keyPress = function(ev) { Terminal.prototype.keyPress = function(ev) {
var key; var key;
cancel(ev); this.cancel(ev);
if (ev.charCode) { if (ev.charCode) {
key = ev.charCode; key = ev.charCode;
@@ -5616,9 +5619,15 @@ function off(el, type, handler, capture) {
} }
function cancel(ev) { function cancel(ev) {
if (ev.preventDefault) ev.preventDefault(); if (!this.cancelEvents) {
ev.returnValue = false; return;
if (ev.stopPropagation) ev.stopPropagation(); }
if (ev.preventDefault) {
ev.preventDefault();
}
if (ev.stopPropagation) {
ev.stopPropagation();
}
ev.cancelBubble = true; ev.cancelBubble = true;
return false; return false;
} }