]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Correct blur/focus delegation
authorDaniel Imms <daimms@microsoft.com>
Fri, 22 Jul 2016 11:13:59 +0000 (04:13 -0700)
committerDaniel Imms <daimms@microsoft.com>
Fri, 22 Jul 2016 11:14:05 +0000 (04:14 -0700)
Focus and blur events on the Terminal object are delegated to the textarea
which handles everything.

src/xterm.js

index 13d3494fb9ecca65bd55cca33ab3b2b87e0fc530..39b4eb16316f83605c26fe1a6b5efa9699e2a99b 100644 (file)
      * Focus the terminal. Delegates focus handling to the terminal's DOM element.
      */
     Terminal.prototype.focus = function() {
-      return this.element.focus();
+      return this.textarea.focus();
     };
 
     /**
      * @static
      */
     Terminal.bindFocus = function (term) {
-      on(term.element, 'focus', function (ev) {
-        if (Terminal.focus === term) {
-          return;
-        }
-
+      on(term.textarea, 'focus', function (ev) {
         if (term.sendFocus) {
           term.send('\x1b[I');
         }
-
         term.element.classList.add('focus');
         term.showCursor();
-        term.textarea.focus();
         Terminal.focus = term;
         term.emit('focus', {terminal: term});
       });
      * Blur the terminal. Delegates blur handling to the terminal's DOM element.
      */
     Terminal.prototype.blur = function() {
-      return this.element.blur();
+      return this.textarea.blur();
     };
 
     /**
      * @static
      */
     Terminal.bindBlur = function (term) {
-      on(term.element, 'blur', function (ev) {
-        if (Terminal.focus !== term) {
-          return;
-        }
-        term.element.classList.remove('focus');
+      on(term.textarea, 'blur', function (ev) {
         term.refresh(term.y, term.y);
-        term.textarea.blur();
         if (term.sendFocus) {
           term.send('\x1b[O');
         }
+        term.element.classList.remove('focus');
         Terminal.focus = null;
         term.emit('blur', {terminal: term});
       });