From 4021e9d487fd8bbe6060eaddcb40f69f4b55edc0 Mon Sep 17 00:00:00 2001 From: Bussonnier Matthias Date: Thu, 15 Jan 2015 12:10:24 +0100 Subject: [PATCH] Do not leave toolbar element focused. Can lead to enter re-trigerring them (ok, can be a feature sometimes I guess) closes #7475 --- IPython/html/static/notebook/js/actions.js | 6 ++++++ IPython/html/static/notebook/js/maintoolbar.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/IPython/html/static/notebook/js/actions.js b/IPython/html/static/notebook/js/actions.js index 13ff5b509..40816144e 100644 --- a/IPython/html/static/notebook/js/actions.js +++ b/IPython/html/static/notebook/js/actions.js @@ -102,7 +102,10 @@ define(function(require){ icon: 'fa-cut', help_index : 'ee', handler : function (env) { + var index = env.notebook.get_selected_index(); env.notebook.cut_cell(); + env.notebook.select(index); + env.notebook.focus_cell(); } }, 'copy-selected-cell' : { @@ -110,6 +113,7 @@ define(function(require){ help_index : 'ef', handler : function (env) { env.notebook.copy_cell(); + env.notebook.focus_cell(); } }, 'paste-cell-before' : { @@ -257,6 +261,7 @@ define(function(require){ help_index : 'ha', handler : function (env) { env.notebook.kernel.interrupt(); + env.notebook.focus_cell(); } }, 'restart-kernel':{ @@ -264,6 +269,7 @@ define(function(require){ help_index : 'hb', handler : function (env) { env.notebook.restart_kernel(); + env.notebook.focus_cell(); } }, 'undo-last-cell-deletion' : { diff --git a/IPython/html/static/notebook/js/maintoolbar.js b/IPython/html/static/notebook/js/maintoolbar.js index 9ecc146bc..cced88c1f 100644 --- a/IPython/html/static/notebook/js/maintoolbar.js +++ b/IPython/html/static/notebook/js/maintoolbar.js @@ -101,6 +101,7 @@ define([ default: console.log("unrecognized cell type:", cell_type); } + that.notebook.focus_cell(); }); return sel; @@ -123,6 +124,7 @@ define([ celltoolbar.CellToolbar.activate_preset(val, that.events); that.notebook.metadata.celltoolbar = val; } + that.notebook.focus_cell(); }); // Setup the currently registered presets. var presets = celltoolbar.CellToolbar.list_presets();