]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
auto emit blur and focus of textarea
authorTDaglis <ath.daglis@gmail.com>
Mon, 26 Oct 2015 15:07:15 +0000 (15:07 +0000)
committerTDaglis <ath.daglis@gmail.com>
Mon, 26 Oct 2015 15:07:15 +0000 (15:07 +0000)
src/xterm.js

index bae41c2b389a2e32ce26f55869b62be597c0a65c..c5050f072dea3d321548f24e3dbe0a698fe98451 100644 (file)
@@ -40,7 +40,7 @@
     } else {
         /*
          * Plain browser environment
-         */ 
+         */
         this.Xterm = xterm.call(this);
         this.Terminal = this.Xterm; /* Backwards compatibility with term.js */
     }
       this.showCursor();
       this.textarea.focus();
 
-      this.emit('focus', {terminal: this});
     };
 
     Terminal.prototype.blur = function() {
       if (this.sendFocus) {
         this.send('\x1b[O');
       }
-
-      this.emit('blur', {terminal: this});
     };
 
     /**
       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++) {
 
       this.emit('keydown', ev);
       this.emit('key', key, ev);
-      this.showCursor();  
+      this.showCursor();
       this.handler(key);
 
       return this.cancel(ev);
     Terminal.cancel = cancel;
 
     return Terminal;
-});
\ No newline at end of file
+});