summaryrefslogtreecommitdiff
path: root/scripts/gui-common
diff options
context:
space:
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 3762e92..86bc5b1 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.
@@ -106,6 +108,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{
/** @param {TouchEvent} event */
#emitTouchEvent(event)
{
+ 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
@@ -141,6 +155,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
@@ -153,6 +171,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
@@ -649,7 +671,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)
{