Browse Source

Avoid deprectated deactivate-request in favor of blur event

Steven Silvester 8 years ago
parent
commit
e2864b815d
3 changed files with 15 additions and 15 deletions
  1. 0 1
      src/application/shell.ts
  2. 0 7
      src/notebook/notebook/panel.ts
  3. 15 7
      src/notebook/notebook/widget.ts

+ 0 - 1
src/application/shell.ts

@@ -156,7 +156,6 @@ class ApplicationShell extends Widget {
         args.newValue.title.className += ` ${CURRENT_CLASS}`;
       }
       if (args.oldValue) {
-        args.oldValue.deactivate();
         let title = args.oldValue.title;
         title.className = title.className.replace(CURRENT_CLASS, '');
       }

+ 0 - 7
src/notebook/notebook/panel.ts

@@ -227,13 +227,6 @@ class NotebookPanel extends Widget {
     this.activated.emit(void 0);
   }
 
-  /**
-   * Handle `'deactivate-request'` messages.
-   */
-  protected onDeactivateRequest(msg: Message): void {
-    this.content.deactivate();
-  }
-
   /**
    * Handle a change to the document context.
    *

+ 15 - 7
src/notebook/notebook/widget.ts

@@ -745,6 +745,9 @@ class Notebook extends StaticNotebook {
     case 'focus':
       this._evtFocus(event as MouseEvent);
       break;
+    case 'blur':
+      this._evtBlur(event as MouseEvent);
+      break;
     default:
       break;
     }
@@ -758,6 +761,7 @@ class Notebook extends StaticNotebook {
     this.node.addEventListener('mousedown', this);
     this.node.addEventListener('dblclick', this);
     this.node.addEventListener('focus', this, true);
+    this.node.addEventListener('blur', this, true);
   }
 
   /**
@@ -767,6 +771,7 @@ class Notebook extends StaticNotebook {
     this.node.removeEventListener('mousedown', this);
     this.node.removeEventListener('dblclick', this);
     this.node.removeEventListener('focus', this, true);
+    this.node.removeEventListener('blur', this, true);
   }
 
   /**
@@ -776,13 +781,6 @@ class Notebook extends StaticNotebook {
     this.node.focus();
   }
 
-  /**
-   * Handle `'deactivate-request'` messages.
-   */
-  protected onDeactivateRequest(msg: Message): void {
-    this.mode = 'command';
-  }
-
   /**
    * Handle `update-request` messages sent to the widget.
    */
@@ -960,6 +958,16 @@ class Notebook extends StaticNotebook {
     }
   }
 
+  /**
+   * Handle `blur` events for the widget.
+   */
+  private _evtBlur(event: MouseEvent): void {
+    let target = event.relatedTarget as HTMLElement;
+    if (!this.node.contains(target)) {
+      this.mode = 'command';
+    }
+  }
+
   /**
    * Handle `dblclick` events for the widget.
    */