From f52fa96a959d7e47419ef57fb439fe458d23c264 Mon Sep 17 00:00:00 2001 From: qcc Date: Tue, 11 Sep 2018 10:40:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=9B=91=E5=90=ACjq=E7=9A=84?= =?UTF-8?q?focus=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/base.js | 16 +++++++++++----- src/base/single/input/input.js | 9 +++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dist/base.js b/dist/base.js index e09a8a02a..255e9cdad 100644 --- a/dist/base.js +++ b/dist/base.js @@ -8490,8 +8490,9 @@ BI.Editor = BI.inherit(BI.Single, { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); }); - this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { - self.watermark && self.watermark.invisible(); + this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) { + // tab键就不要隐藏了 + self.watermark && e.keyCode !== 9 && self.watermark.invisible(); }); this.editor.on(BI.Input.EVENT_VALID, function () { @@ -9731,6 +9732,10 @@ BI.Input = BI.inherit(BI.Single, { "leading": true, "trailing": false }); + this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { "leading": true, "trailing": false @@ -9739,7 +9744,7 @@ BI.Input = BI.inherit(BI.Single, { .keydown(function (e) { inputEventValid = false; ctrlKey = e.ctrlKey; - self.fireEvent(BI.Input.EVENT_QUICK_DOWN); + self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments); }) .keyup(function (e) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { @@ -9762,6 +9767,9 @@ BI.Input = BI.inherit(BI.Single, { .mousedown(function (e) { self.element.val(self.element.val()); }) + .focus(function (e) { // 可以不用冒泡 + self._focusDebounce(); + }) .focusout(function (e) { self._blurDebounce(); }); @@ -9809,7 +9817,6 @@ BI.Input = BI.inherit(BI.Single, { _click: function () { if (this._isEditing !== true) { - this._focus(); this.selectAll(); this.fireEvent(BI.Input.EVENT_CLICK); } @@ -9910,7 +9917,6 @@ BI.Input = BI.inherit(BI.Single, { } if (!this._isEditing === true) { this.element.focus(); - this._focus(); this.selectAll(); } }, diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index dc59b08a9..6a15ab788 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -29,6 +29,10 @@ BI.Input = BI.inherit(BI.Single, { "leading": true, "trailing": false }); + this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { "leading": true, "trailing": false @@ -60,6 +64,9 @@ BI.Input = BI.inherit(BI.Single, { .mousedown(function (e) { self.element.val(self.element.val()); }) + .focus(function (e) { // 可以不用冒泡 + self._focusDebounce(); + }) .focusout(function (e) { self._blurDebounce(); }); @@ -107,7 +114,6 @@ BI.Input = BI.inherit(BI.Single, { _click: function () { if (this._isEditing !== true) { - this._focus(); this.selectAll(); this.fireEvent(BI.Input.EVENT_CLICK); } @@ -208,7 +214,6 @@ BI.Input = BI.inherit(BI.Single, { } if (!this._isEditing === true) { this.element.focus(); - this._focus(); this.selectAll(); } },