From 00d1183947b3f2cd6aa08e3e0960c863fb62e349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Thu, 12 Sep 2013 17:13:34 +0200 Subject: [PATCH] [FIX] point_of_sale: onscreen keyboard would stop working when category changed + make it disappear outside product screen bzr revid: fva@openerp.com-20130912151334-c3kc4c4137amrl9f --- addons/point_of_sale/static/src/js/screens.js | 6 +++--- .../static/src/js/widget_keyboard.js | 15 +++++++-------- addons/point_of_sale/static/src/js/widgets.js | 3 +++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 20253ffd27b..975c7fc6286 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -762,9 +762,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this.product_categories_widget.reset_category(); this.pos_widget.order_widget.set_numpad_state(this.pos_widget.numpad.state); - if(this.pos.iface_vkeyboard){ - this.pos_widget.onscreen_keyboard.connect(); - } if(this.pos_widget.screen_selector.current_mode === 'client'){ this.add_action_button({ @@ -781,6 +778,9 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa this._super(); this.pos_widget.order_widget.set_numpad_state(null); this.pos_widget.payment_screen.set_numpad_state(null); + if(this.pos.iface_vkeyboard && this.pos_widget.onscreen_keyboard){ + this.pos_widget.onscreen_keyboard.hide(); + } }, }); diff --git a/addons/point_of_sale/static/src/js/widget_keyboard.js b/addons/point_of_sale/static/src/js/widget_keyboard.js index 2e683edb1e1..05ccdd78ca6 100644 --- a/addons/point_of_sale/static/src/js/widget_keyboard.js +++ b/addons/point_of_sale/static/src/js/widget_keyboard.js @@ -27,9 +27,7 @@ function openerp_pos_keyboard(instance, module){ //module is instance.point_of_s } this.input_selector = options.input_selector || '.searchbox input'; - - //show the keyboard when the input zone is clicked. - $(this.input_selector).focus(function(){self.show();}); + this.$target = null; //Keyboard state this.capslock = false; @@ -37,14 +35,15 @@ function openerp_pos_keyboard(instance, module){ //module is instance.point_of_s this.numlock = false; }, - connect : function(){ + connect : function($target){ var self = this; - $(this.input_selector).focus(function(){self.show();}); + this.$target = $target; + $target.focus(function(){self.show();}); }, // Write a character to the input zone writeCharacter: function(character){ - var $input = $(this.input_selector); + var $input = this.$target $input[0].value += character; $input.keydown(); $input.keyup(); @@ -56,7 +55,7 @@ function openerp_pos_keyboard(instance, module){ //module is instance.point_of_s // Removes the last character from the input zone. deleteCharacter: function(){ - var $input = $(this.input_selector); + var $input = this.$target; var input_value = $input[0].value; $input[0].value = input_value.substr(0, input_value.length - 1); $input.keydown(); @@ -65,7 +64,7 @@ function openerp_pos_keyboard(instance, module){ //module is instance.point_of_s // Clears the content of the input zone. deleteAllCharacters: function(){ - var $input = $(this.input_selector); + var $input = this.$target; $input[0].value = ""; $input.keydown(); $input.keyup(); diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 24660ab6377..25fb58f77f1 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -541,6 +541,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa self.renderElement(); self.search_and_categories(category); }); + if(this.pos.iface_vkeyboard && this.pos_widget.onscreen_keyboard){ + this.pos_widget.onscreen_keyboard.connect(this.$('.searchbox input')); + } this.search_and_categories(); },