From 987f09d88051e97ab399c8b9ae826d46d95d178b Mon Sep 17 00:00:00 2001 From: TDaglis Date: Mon, 26 Oct 2015 15:07:15 +0000 Subject: [PATCH] auto emit blur and focus of textarea --- src/xterm.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index bae41c2b..c5050f07 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -40,7 +40,7 @@ } else { /* * Plain browser environment - */ + */ this.Xterm = xterm.call(this); this.Terminal = this.Xterm; /* Backwards compatibility with term.js */ } @@ -394,7 +394,6 @@ this.showCursor(); this.textarea.focus(); - this.emit('focus', {terminal: this}); }; Terminal.prototype.blur = function() { @@ -408,8 +407,6 @@ if (this.sendFocus) { this.send('\x1b[O'); } - - this.emit('blur', {terminal: this}); }; /** @@ -559,6 +556,12 @@ this.textarea.setAttribute('autocapitalize', 'off'); this.textarea.setAttribute('spellcheck', 'false'); this.textarea.tabIndex = 0; + this.textarea.onfocus = function() { + self.emit('focus', {terminal: self}); + } + this.textarea.onblur = function() { + self.emit('blur', {terminal: self}); + } this.helperContainer.appendChild(this.textarea); for (; i < this.rows; i++) { @@ -2379,7 +2382,7 @@ this.emit('keydown', ev); this.emit('key', key, ev); - this.showCursor(); + this.showCursor(); this.handler(key); return this.cancel(ev); @@ -4784,4 +4787,4 @@ Terminal.cancel = cancel; return Terminal; -}); \ No newline at end of file +});