From 266812564d7905212943f699cc439fcf21d85d26 Mon Sep 17 00:00:00 2001
From: Kyle Gunger <kgunger12@gmail.com>
Date: Fri, 15 Nov 2024 03:03:48 -0500
Subject: Correct event handling for select button widget

---
 scripts/gui-common/widgets.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'scripts/gui-common')

diff --git a/scripts/gui-common/widgets.js b/scripts/gui-common/widgets.js
index 78402c5..3d9d004 100644
--- a/scripts/gui-common/widgets.js
+++ b/scripts/gui-common/widgets.js
@@ -1108,13 +1108,17 @@ class WidgetSelectButton extends Widget
 			if(this.#selected.length > 0)
 			{
 				let swap = this.#selected.shift();
-				this.#swgs[swap].set(-swap - 1);
+                this.#swgs[swap].removeEventListener("change", this.#binder);
+			    this.#swgs[swap].set(-swap - 1);
+                this.#swgs[swap].addEventListener("change", this.#binder);
 			}
 			this.#selected.push(idx);
 		}
 		else
 		{
+            this.#swgs[idx].removeEventListener("change", this.#binder);
 			this.#swgs[idx].set(-idx - 1);
+            this.#swgs[idx].addEventListener("change", this.#binder);
 		}
 		
 		if (!this.#removeLastOver && this.#selected.length >= this.#maxSelections)
-- 
cgit v1.2.3