Got an initial event setup that seems to have potential. It looks to be scalable from a single widget to global or in between without too much work. type IncrementBar = object target: float proc animatedProgress*(delta: float32 = 0.1) {.statefulFidget.} = properties: value: float self.value = self.value + delta ## handle events var v {.inject.}: Variant if not current.hookEvents.isNil and current.hookEvents.pop(current.code, v): variantMatch case v as evt of IncrementBar: echo "pbar event: ", evt.repr() self.value = self.value + evt.target refresh() else: echo "dont know what v is" ... Run
Then: proc exampleApp*(myName {.property: name.}: string) {.appFidget.} = ## defines a stateful app widget properties: count1: int count2: int value: UnitRange if current.hookEvents.isNil: current.hookEvents = newTable[string, Variant]() let currEvents = current.hookEvents ... # Trigger an animation on animatedProgress below Widget button: text: fmt"Animate {self.count2:4d}" onClick: self.count2.inc() currEvents["pbc1"] = newVariant(IncrementBar(target: 0.02)) Widget animatedProgress: delta: delta setup: box 0'em, 0'em, 14'em, 2.Em current.code = "pbc1" current.hookEvents = currEvents Widget button: text: fmt"Animate2 {self.count2:4d}" onClick: self.count2.inc() currEvents["pbc1"] = newVariant(IncrementBar(target: 0.02)) Run