summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/gui-common/widgets.js24
-rw-r--r--scripts/main.js7
2 files changed, 28 insertions, 3 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)
{
diff --git a/scripts/main.js b/scripts/main.js
index e67cff3..bda7798 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -8,8 +8,8 @@ class Client {
/** @type {DescAny[]} */
let desc = [
{ type: "button", name: "bt", props: {}, },
- { type: "checkbox", name: "cb", props: {}, state: true },
- { type: "toggle", name: "tg", props: {}, state: false },
+ { type: "checkbox", name: "cb", props: {}, state: false },
+ { type: "toggle", name: "tg", props: {}, state: true },
{ type: "slider", name: "sli", props: {max: 10, min: 1, percent: true}, state: 6 },
{ type: "color-light", name: "cli", state: 0.7 },
{ type: "color-temp", name: "ctp", state: 3000 },
@@ -32,6 +32,9 @@ class Client {
{
if (e.detail.name == "scb" && e.detail.changed == "value")
this.set.widgets["thm"].set(Temperature.from_celcius(e.detail.value));
+
+ if (e.detail.name == "cb" && e.detail.changed == "value")
+ WIDGETS_DEBUG = !(!(e.detail.value))
}
}