From 793df8a2036db582b2f396e660acadb0fb5d0e45 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Tue, 1 Feb 2022 14:25:28 +0100 Subject: [PATCH 1/8] _button On mouse down Mouse move event as always button === 0 event when dragigng with right click-press . Therefore this._button need to be updated --- src/nonvisual/mousemanager.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/nonvisual/mousemanager.js b/src/nonvisual/mousemanager.js index f8cbef01..d36ba469 100644 --- a/src/nonvisual/mousemanager.js +++ b/src/nonvisual/mousemanager.js @@ -506,31 +506,23 @@ var MouseManager = Base.$extend({ // Load the current state this._action = action; this.__event = event; - this._button = null; - if (event.button === 0) { - this._button = "left"; - } - if (event.button === 1) { - this._button = "middle"; - } - if (event.button === 2) { - this._button = "right"; - } - // Analyze the event // Mouse Down / Mouse Up if (action == "mouse-down") { this.__mouseDownEvent = event; - + if (event.button === 0) { this._btnLeft = true; + this._button = "left"; } if (event.button === 1) { this._btnMiddle = true; + this._button = "middle"; } if (event.button === 2) { this._btnRight = true; + this._button = "right"; } this._callCallbacks("mouse-event", [this._dump()]); From 774e82f8f0d80fd0b22a15516c2db93fb4999bc1 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Fri, 4 Feb 2022 11:32:49 +0100 Subject: [PATCH 2/8] Update src/nonvisual/mousemanager.js Co-authored-by: Thomas Fromont --- src/nonvisual/mousemanager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nonvisual/mousemanager.js b/src/nonvisual/mousemanager.js index d36ba469..fff89d6d 100644 --- a/src/nonvisual/mousemanager.js +++ b/src/nonvisual/mousemanager.js @@ -511,7 +511,6 @@ var MouseManager = Base.$extend({ // Mouse Down / Mouse Up if (action == "mouse-down") { this.__mouseDownEvent = event; - if (event.button === 0) { this._btnLeft = true; this._button = "left"; From 10ddc8feda3e155010c32b87a368703cf1c33542 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Wed, 16 Feb 2022 14:56:41 +0100 Subject: [PATCH 3/8] Update mousemanager.js --- src/nonvisual/mousemanager.js | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/nonvisual/mousemanager.js b/src/nonvisual/mousemanager.js index fff89d6d..9d8ccb75 100644 --- a/src/nonvisual/mousemanager.js +++ b/src/nonvisual/mousemanager.js @@ -132,6 +132,7 @@ var MouseManager = Base.$extend({ } else { this.$super(element); } + this.__dragStartButton = null; // used for state manager }, ////////////////////////////////////////// @@ -460,8 +461,7 @@ var MouseManager = Base.$extend({ this._bindEvent("mouse-up", this.element, "mouseup", this.__onMouseUp.bind(this)); this._bindEvent("double-click", this.element, "dblclick", this.__onDoubleClick.bind(this)); this._bindEvent("mouse-move", this.element, "mousemove", this.__onMouseMove.bind(this)); - this._bindEvent("mousewheel", this.element, "mousewheel", this.__onMouseWheel.bind(this)); - this._bindEvent("mousewheel-firefox", this.element, "DOMMouseScroll", this.__onMouseWheel.bind(this)); + this._bindEvent("wheel", this.element, "wheel", this.__onWheel.bind(this)); this._bindEvent("document-mouse-up", document, "mouseup", this.__onDocumentMouseUp.bind(this)); this._bindEvent("document-mouse-move", document, "mousemove", this.__onDocumentMouseMove.bind(this)); @@ -506,22 +506,34 @@ var MouseManager = Base.$extend({ // Load the current state this._action = action; this.__event = event; + this._button = null; + if (this.__dragStartButton) { + this._button = this.__dragStartButton; + } + else if (event.button === 0) { + this._button = "left"; + } + else if (event.button === 1) { + this._button = "middle"; + } + else if (event.button === 2) { + this._button = "right"; + } + // Analyze the event // Mouse Down / Mouse Up if (action == "mouse-down") { this.__mouseDownEvent = event; + if (event.button === 0) { this._btnLeft = true; - this._button = "left"; } if (event.button === 1) { this._btnMiddle = true; - this._button = "middle"; } if (event.button === 2) { this._btnRight = true; - this._button = "right"; } this._callCallbacks("mouse-event", [this._dump()]); @@ -577,6 +589,7 @@ var MouseManager = Base.$extend({ this.__prevState.action != "dragging" && (this.btnLeft || this.btnMiddle || this.btnRight)) { if (Math.abs(this.pageX - this.__mouseDownEvent.pageX) > this._threshold || Math.abs(this.pageY - this.__mouseDownEvent.pageY) > this._threshold) { + this.__dragStartButton = this._button; // Drag Start this._action = "drag-start"; this.__event = this.__mouseDownEvent; @@ -601,6 +614,7 @@ var MouseManager = Base.$extend({ } else if (action == "drag-end" || (action == "mouse-up" && (this.__prevState.action == "dragging" || this.__prevState.action == "drag-start") && !(this.btnLeft || this.btnMiddle || this.btnRight))) { this._action = "drag-end"; + this.__dragStartButton = null; this._callCallbacks("mouse-event", [this._dump()]); this._callCallbacks(this.action, [this._dump()]); } @@ -665,6 +679,11 @@ var MouseManager = Base.$extend({ } if (this.action == "dragging" || this.action == "drag-start") { this._stateMachine("drag-end", event); + } else if (event.button === 0 && this._btnLeft || + event.button === 1 && this._btnMiddle || + event.button === 2 && this._btnRight) { + + this._stateMachine("mouse-up", event); } }, @@ -685,26 +704,15 @@ var MouseManager = Base.$extend({ }, /** - * @method __onMouseWheel + * @method __onWheel * @private * @param event */ - __onMouseWheel: function (event) { + __onWheel: function (event) { var wheelDelta = null; - // Webkit - if (event.wheelDeltaY !== undefined) { - wheelDelta = event.wheelDeltaY; - } - // MSIE - if (event.wheelDelta !== undefined) { - wheelDelta = event.wheelDelta; - } - // Firefox - if (event.axis !== undefined && event.detail !== undefined) { - if (event.axis == 2) { // Y - wheelDelta = -event.detail; - } + if (event.deltaY !== undefined) { + wheelDelta = -event.deltaY; } if (wheelDelta !== null) { From 02c8bb91d04401cfe1340a3034da0679a53db145 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Thu, 23 Mar 2023 17:53:52 +0100 Subject: [PATCH 4/8] Correct memory leak Call the destroy function of the child node. --- src/composite/select.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/composite/select.js b/src/composite/select.js index b7b0c50a..8266c1cb 100644 --- a/src/composite/select.js +++ b/src/composite/select.js @@ -114,9 +114,10 @@ var Select = Widget.$extend({ } this._value = ""; - var item = new MenuItem({text: this.placeholder, className: "photonui-select-placeholder"}); + if (this.__displayValue) this.__displayValue.destroy(); + this.__displayValue = new MenuItem({text: this.placeholder, className: "photonui-select-placeholder"}); Helpers.cleanNode(this.__html.select); - this.__html.select.appendChild(item.html); + this.__html.select.appendChild(this.__displayValue.html); }, /** @@ -325,8 +326,9 @@ var Select = Widget.$extend({ * @method destroy */ destroy: function () { - this.__popupMenu.destroy(); - this.$super(); + if (this.__displayValue) this.__displayValue.destroy() + if(this.__popupMenu) this.__popupMenu.destroy() + this.$super() }, // ====== Private methods ====== From adf690219e1de25b62499757aeb38fb0eb16953f Mon Sep 17 00:00:00 2001 From: Rincelent Date: Thu, 23 Mar 2023 17:59:37 +0100 Subject: [PATCH 5/8] Revert unrelated change --- src/nonvisual/mousemanager.js | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/nonvisual/mousemanager.js b/src/nonvisual/mousemanager.js index 9d8ccb75..f8cbef01 100644 --- a/src/nonvisual/mousemanager.js +++ b/src/nonvisual/mousemanager.js @@ -132,7 +132,6 @@ var MouseManager = Base.$extend({ } else { this.$super(element); } - this.__dragStartButton = null; // used for state manager }, ////////////////////////////////////////// @@ -461,7 +460,8 @@ var MouseManager = Base.$extend({ this._bindEvent("mouse-up", this.element, "mouseup", this.__onMouseUp.bind(this)); this._bindEvent("double-click", this.element, "dblclick", this.__onDoubleClick.bind(this)); this._bindEvent("mouse-move", this.element, "mousemove", this.__onMouseMove.bind(this)); - this._bindEvent("wheel", this.element, "wheel", this.__onWheel.bind(this)); + this._bindEvent("mousewheel", this.element, "mousewheel", this.__onMouseWheel.bind(this)); + this._bindEvent("mousewheel-firefox", this.element, "DOMMouseScroll", this.__onMouseWheel.bind(this)); this._bindEvent("document-mouse-up", document, "mouseup", this.__onDocumentMouseUp.bind(this)); this._bindEvent("document-mouse-move", document, "mousemove", this.__onDocumentMouseMove.bind(this)); @@ -507,16 +507,13 @@ var MouseManager = Base.$extend({ this._action = action; this.__event = event; this._button = null; - if (this.__dragStartButton) { - this._button = this.__dragStartButton; - } - else if (event.button === 0) { + if (event.button === 0) { this._button = "left"; } - else if (event.button === 1) { + if (event.button === 1) { this._button = "middle"; } - else if (event.button === 2) { + if (event.button === 2) { this._button = "right"; } @@ -589,7 +586,6 @@ var MouseManager = Base.$extend({ this.__prevState.action != "dragging" && (this.btnLeft || this.btnMiddle || this.btnRight)) { if (Math.abs(this.pageX - this.__mouseDownEvent.pageX) > this._threshold || Math.abs(this.pageY - this.__mouseDownEvent.pageY) > this._threshold) { - this.__dragStartButton = this._button; // Drag Start this._action = "drag-start"; this.__event = this.__mouseDownEvent; @@ -614,7 +610,6 @@ var MouseManager = Base.$extend({ } else if (action == "drag-end" || (action == "mouse-up" && (this.__prevState.action == "dragging" || this.__prevState.action == "drag-start") && !(this.btnLeft || this.btnMiddle || this.btnRight))) { this._action = "drag-end"; - this.__dragStartButton = null; this._callCallbacks("mouse-event", [this._dump()]); this._callCallbacks(this.action, [this._dump()]); } @@ -679,11 +674,6 @@ var MouseManager = Base.$extend({ } if (this.action == "dragging" || this.action == "drag-start") { this._stateMachine("drag-end", event); - } else if (event.button === 0 && this._btnLeft || - event.button === 1 && this._btnMiddle || - event.button === 2 && this._btnRight) { - - this._stateMachine("mouse-up", event); } }, @@ -704,15 +694,26 @@ var MouseManager = Base.$extend({ }, /** - * @method __onWheel + * @method __onMouseWheel * @private * @param event */ - __onWheel: function (event) { + __onMouseWheel: function (event) { var wheelDelta = null; - if (event.deltaY !== undefined) { - wheelDelta = -event.deltaY; + // Webkit + if (event.wheelDeltaY !== undefined) { + wheelDelta = event.wheelDeltaY; + } + // MSIE + if (event.wheelDelta !== undefined) { + wheelDelta = event.wheelDelta; + } + // Firefox + if (event.axis !== undefined && event.detail !== undefined) { + if (event.axis == 2) { // Y + wheelDelta = -event.detail; + } } if (wheelDelta !== null) { From 9dc5ece0897fe22d3a51d131d413bc662cd229f2 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Fri, 24 Mar 2023 11:07:20 +0100 Subject: [PATCH 6/8] Update src/composite/select.js --- src/composite/select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/composite/select.js b/src/composite/select.js index 8266c1cb..b5eb7ab1 100644 --- a/src/composite/select.js +++ b/src/composite/select.js @@ -327,7 +327,7 @@ var Select = Widget.$extend({ */ destroy: function () { if (this.__displayValue) this.__displayValue.destroy() - if(this.__popupMenu) this.__popupMenu.destroy() + if (this.__popupMenu) this.__popupMenu.destroy() this.$super() }, From 5b4a4f1eaae05e415b22c60a195e3e4d3d038df2 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Fri, 31 Mar 2023 11:24:30 +0200 Subject: [PATCH 7/8] Update select.js Add missing ; --- src/composite/select.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composite/select.js b/src/composite/select.js index b5eb7ab1..fd50055d 100644 --- a/src/composite/select.js +++ b/src/composite/select.js @@ -326,9 +326,9 @@ var Select = Widget.$extend({ * @method destroy */ destroy: function () { - if (this.__displayValue) this.__displayValue.destroy() - if (this.__popupMenu) this.__popupMenu.destroy() - this.$super() + if (this.__displayValue) this.__displayValue.destroy(); + if (this.__popupMenu) this.__popupMenu.destroy(); + this.$super(); }, // ====== Private methods ====== From 2c013f9450f5f62a0dbc035f2ed19b80694f35e2 Mon Sep 17 00:00:00 2001 From: Rincelent Date: Fri, 31 Mar 2023 11:48:32 +0200 Subject: [PATCH 8/8] Update select.js Lint --- src/composite/select.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/composite/select.js b/src/composite/select.js index fd50055d..911a1aed 100644 --- a/src/composite/select.js +++ b/src/composite/select.js @@ -114,7 +114,9 @@ var Select = Widget.$extend({ } this._value = ""; - if (this.__displayValue) this.__displayValue.destroy(); + if (this.__displayValue) { + this.__displayValue.destroy(); + } this.__displayValue = new MenuItem({text: this.placeholder, className: "photonui-select-placeholder"}); Helpers.cleanNode(this.__html.select); this.__html.select.appendChild(this.__displayValue.html); @@ -326,8 +328,12 @@ var Select = Widget.$extend({ * @method destroy */ destroy: function () { - if (this.__displayValue) this.__displayValue.destroy(); - if (this.__popupMenu) this.__popupMenu.destroy(); + if (this.__displayValue) { + this.__displayValue.destroy(); + } + if (this.__popupMenu) { + this.__popupMenu.destroy(); + } this.$super(); },