From eb3b60abb6ccf8fb2731061bc856b3960d698683 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 05:17:29 -0600 Subject: block events for disable widgets --- common.go | 7 +++++++ init.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/common.go b/common.go index 1644ff2..0388ac6 100644 --- a/common.go +++ b/common.go @@ -62,6 +62,13 @@ func (n *Node) Hide() *Node { return n } +func (n *Node) IsEnabled() bool { + if !n.Ready() { + return false + } + return n.enabled +} + // enables a widget so the user can see it and work/click/etc on it // by default, widgets are enabled when they are created func (n *Node) Enable() *Node { diff --git a/init.go b/init.go index 3883fa1..72b577d 100644 --- a/init.go +++ b/init.go @@ -223,6 +223,11 @@ func watchCallback() { func (n *Node) gotUserEvent(a widget.Action) { log.Log(CHANGE, "gotUserEvent() received event node =", n.id, n.progname, a.Value) + if !n.IsEnabled() { + log.Log(WARN, "ignoring plugin event for a disabled widget", n.id, n.progname, a.Value) + return + } + switch n.WidgetType { case widget.Dropdown: // n.checked = a.State.Checked // TODO: do this and/or time to switch to protobuf -- cgit v1.2.3