Clear selected range on entering edit mode

This commit is contained in:
Thomas Kluyver 2015-08-09 18:19:48 -07:00
parent 92e266f4e2
commit dcd676d499
2 changed files with 20 additions and 0 deletions

View File

@ -122,6 +122,13 @@ define(function(require){
}
}
},
'reset-selection': {
help: 'clear selected cells',
help_index: 'de',
handler: function(env) {
env.notebook.reset_selection();
}
},
'cut-selected-cell' : {
icon: 'fa-cut',
help_index : 'ee',

View File

@ -725,6 +725,18 @@ define(function (require) {
return true;
};
/**
* Clear selection of multiple cells (except the cell at the cursor)
*/
Notebook.prototype.reset_selection = function() {
var current_selection = this.get_selected_cells();
for (var i=0; i<current_selection.length; i++) {
if (!current_selection[i].selected) {
current_selection[i].unselect()
}
}
};
// Edit/Command mode
@ -778,6 +790,7 @@ define(function (require) {
if (cell && this.mode !== 'edit') {
cell.edit_mode();
this.mode = 'edit';
this.reset_selection();
this.events.trigger('edit_mode.Notebook');
this.keyboard_manager.edit_mode();
}