summaryrefslogtreecommitdiff
path: root/scripts/gui-common
diff options
context:
space:
mode:
authorCircleShift <kgunger12@gmail.com>2025-12-20 11:18:55 -0500
committerCircleShift <kgunger12@gmail.com>2025-12-20 11:18:55 -0500
commit96c8d99ec74acad6f0c99d4d7c006a67ee7d643e (patch)
tree19d62b5d7f258afc343ba04ae28720c8fb60a3a1 /scripts/gui-common
parent04c9c0d1f06ebf4fa2aa234a00838bc198c734e3 (diff)
Add debug mode
Diffstat (limited to 'scripts/gui-common')
-rw-r--r--scripts/gui-common/widgets.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/scripts/gui-common/widgets.js b/scripts/gui-common/widgets.js
index 05d6126..f14fb22 100644
--- a/scripts/gui-common/widgets.js
+++ b/scripts/gui-common/widgets.js
@@ -1,5 +1,7 @@
'use strict';
+var WIDGETS_DEBUG = false;
+
/**
* The base Widget class. Represents an interactible
* value-producing object in the browser, like an input.
@@ -103,6 +105,10 @@ class Widget extends EventTarget{
/** @param {MouseEvent} event */
#emitMouseEvent(event)
{
+ if (WIDGETS_DEBUG) {
+ console.log(event);
+ }
+
if (this.#inactive)
this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new MouseEvent(event.type, event)}}));
else
@@ -115,6 +121,10 @@ class Widget extends EventTarget{
//if (window.SCROLLING)
// return;
+ if (WIDGETS_DEBUG) {
+ console.log(event);
+ }
+
if (event.type == "touchstart")
this.element.classList.add("touch");
else if (event.type == "touchend" || event.type == "touchcancel")
@@ -130,6 +140,10 @@ class Widget extends EventTarget{
/** @param {KeyboardEvent} event */
#emitKeyboardEvent(event) {
+ if (WIDGETS_DEBUG) {
+ console.log(event);
+ }
+
if (this.#inactive)
this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new KeyboardEvent(event.type, event)}}));
else
@@ -149,6 +163,10 @@ class Widget extends EventTarget{
/** @param {FocusEvent} event */
#emitFocusEvent(event) {
+ if (WIDGETS_DEBUG) {
+ console.log(event);
+ }
+
if (this.#inactive)
this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new FocusEvent(event.type, event)}}));
else
@@ -161,6 +179,10 @@ class Widget extends EventTarget{
/** @param {Event} event */
#emitContextEvent(event)
{
+ if (WIDGETS_DEBUG) {
+ console.log(event);
+ }
+
if (this.#inactive)
this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new Event(event.type, event)}}));
else
@@ -599,7 +621,7 @@ class WidgetDragable extends Widget
return;
}
- if (event.type == "touchend")
+ if (event.type == "touchend" || event.type == "touchcancel")
{
if (this.#touches[event.changedTouches[0].identifier] == 1)
{