changeset 6af100dbc938 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=6af100dbc938
description:
Implement key press event on One2Many
issue3838
review15831002
diffstat:
src/view/form.js | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diffs (40 lines):
diff -r 1b4a4dc6a899 -r 6af100dbc938 src/view/form.js
--- a/src/view/form.js Wed Apr 07 23:34:51 2021 +0200
+++ b/src/view/form.js Sun Apr 11 18:26:39 2021 +0200
@@ -3094,7 +3094,10 @@
this.content.append(this.screen.screen_container.el);
}.bind(this));
- // TODO key_press
+ if (attributes.add_remove) {
+ // Use keydown to not receive focus-in TAB
+ this.wid_text.on('keydown', this.key_press.bind(this));
+ }
this.but_switch.prop('disabled', this.screen.number_of_views <= 0);
},
@@ -3430,6 +3433,24 @@
}
}.bind(this));
},
+ key_press: function(event_) {
+ if (event_.which == Sao.common.F3_KEYCODE) {
+ this.new_(event_);
+ event_.preventDefault();
+ } else if (event_.which == Sao.common.F2_KEYCODE) {
+ this.add(event_);
+ event_.preventDefault();
+ }
+ if (this.attributes.add_remove) {
+ var activate_keys = [Sao.common.TAB_KEYCODE];
+ if (!this.wid_completion) {
+ activate_keys.push(Sao.common.RETURN_KEYCODE);
+ }
+ if (~activate_keys.indexOf(event_.which) &&
this.wid_text.val()) {
+ this.add(event_);
+ }
+ }
+ },
record_label: function(data) {
this._position = data[0];
this._length = data[1];