From 2c21368f2f2f367cff82daf17e3780a5cf09f06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Tue, 28 Jul 2015 13:25:01 +0200 Subject: [PATCH] Focus tree cells in editable trees when switching from one to another review17361002 --- src/view.js | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/view.js b/src/view.js index c2232c404f..eaf8d5c204 100644 --- a/src/view.js +++ b/src/view.js @@ -856,11 +856,12 @@ widget.view = this.tree; this.get_widget_editable().empty().append(widget.el); // We use keydown to be able to catch TAB events - current_td.one('keydown', this.key_press.bind(this)); + widget.el.on('keydown', this.key_press.bind(this)); field = this.record.model.fields[widget.field_name]; widget.display(this.record, field); this.get_widget().hide(); this.get_widget_editable().show(); + widget.focus(); } else { this.set_selection(true); this.selection_changed(); @@ -892,8 +893,6 @@ var current_td, selector, next_column, next_idx, i; var states; - this.get_active_td().one('keydown', - this.key_press.bind(this)); if ((event_.which != Sao.common.TAB_KEYCODE) && (event_.which != Sao.common.UP_KEYCODE) && (event_.which != Sao.common.DOWN_KEYCODE) && @@ -930,7 +929,11 @@ } } window.setTimeout(function() { - this._get_column_td(next_idx).trigger('click'); + var td = this._get_column_td(next_idx); + td.triggerHandler('click', { + column: next_idx, + td: td + }); }.bind(this), 0); } else if (event_.which == Sao.common.UP_KEYCODE || event_.which == Sao.common.DOWN_KEYCODE) { @@ -2125,6 +2128,9 @@ }, set_readonly: function(readonly) { this.input.prop('disabled', readonly); + }, + focus: function() { + this.input.focus(); } }); @@ -2148,7 +2154,7 @@ this.date = this.labelled = jQuery('
', { 'class': 'input-group input-group-sm' }).appendTo(this.el); - jQuery('', { + this.input = jQuery('', { 'type': 'text', 'class': 'form-control input-sm' }).appendTo(this.date); @@ -2187,6 +2193,9 @@ } this.date.data('DateTimePicker').date(value); }, + focus: function() { + this.input.focus(); + }, set_value: function(record, field) { field.set_client(record, this.get_value(record, field)); }, @@ -2246,6 +2255,9 @@ this.input.val(''); } }, + focus: function() { + this.input.focus(); + }, set_value: function(record, field) { field.set_client(record, this.input.val()); }, @@ -2357,6 +2369,9 @@ Sao.View.Form.Selection._super.display.call(this, record, field); this.display_update_selection(record, field); }, + focus: function() { + this.select.focus(); + }, value_get: function() { return JSON.parse(this.select.val()); }, @@ -2391,6 +2406,9 @@ this.input.prop('checked', false); } }, + focus: function() { + this.input.focus(); + }, set_value: function(record, field) { var value = this.input.prop('checked'); field.set_client(record, value); @@ -2422,6 +2440,9 @@ this.input.val(''); } }, + focus: function() { + this.input.focus(); + }, set_value: function(record, field) { var value = this.input.val() || ''; field.set_client(record, value); @@ -2580,6 +2601,9 @@ }}); } }, + focus: function() { + this.entry.focus(); + }, set_readonly: function(readonly) { this._readonly = readonly; this._set_button_sensitive(); @@ -3120,6 +3144,11 @@ this.screen.display(); }.bind(this)); }, + focus: function() { + if (this.wid_text.is(':visible')) { + this.wid_text.focus(); + } + }, activate: function(event_) { this.edit(); }, @@ -3414,6 +3443,9 @@ this.screen.display(); }.bind(this)); }, + focus: function() { + this.entry.focus(); + }, activate: function() { this.edit(); },