commands.add(eml! {
<body>
<entity {label as Label}/>
<label:label/>
<btngroup value:changed={|change, label| label.value=format!(
"value changed from {} to {}", change.from(), change.to()
)}/>
</body>
Change registrators could be done for each widget's #[prop(...)] automatically. ChangeHandlerExpression parser should detect built-in (without type-spec), custom WorldQuery and SystemParam arguments:
this: current widget entity associated with widget main component (it is used as target entity if no $ident provided).
change: Change<T> value with from() and new() methods
$ident - registered associated target entity (like label in example above)
The problem
For now you are required to define change event for each property by hand, like it is done for
<btngroup>
:You can connect to the
value_change
event later:There are several problems with such approach:
Changed<T>
eventrun!(for ...)
macro syntaxctx.old/new_value()
for fetching the change, and its kinda uglyThe solution
When the entity associations (#68) and default widget component (
#todo
) will be done, it is easy to implementchange handler expression
syntax:Change registrators could be done for each widget's
#[prop(...)]
automatically.ChangeHandlerExpression
parser should detect built-in (without type-spec), customWorldQuery
andSystemParam
arguments:this
: current widget entity associated with widget main component (it is used as target entity if no$ident
provided).change
:Change<T>
value withfrom()
andnew()
methods$ident
- registered associated target entity (likelabel
in example above)$ident: &Component
- imutableComponent
access for target entity (liketr: &Transform
)$ident: &mut Component
- mutableComponent
access for target entity (liketr: &mut Transform
)$ident: SystemParam
- mutable access to system param (likecmd: Commands
)There is no
ctx
argument support as far as we do not need context anymore when fetchingSystemParam
in handlers is done.Cahnge detection could be easaly done inside the bind systems (e.g. generate
Change<T>
event when value cahnged.