import { Button, VerticalBox } from "std-widgets.slint";
component Foo {
in property <bool> has-lower: true;
in property <string> upper-text <=> upper.text;
in property <string> lower-text;
callback clicked-upper <=> upper.clicked;
callback clicked-lower;
VerticalBox {
alignment: start;
upper := Button {}
if has-lower : Button {
// This works:
text <=> root.lower-text;
// Why shouldn't this also work, if the two-way-binding
// syntax is okay for callbacks when declaring them,
// and for properties inside used elements?
//clicked <=> root.clicked-lower;
// You currently have to use this syntax. This would
// require you to pass the whole parameter list:
clicked => { root.clicked-lower(); }
}
}
}
export component Demo {
Foo {
upper-text: "0";
lower-text: "0";
clicked-upper => {
self.upper-text = self.upper-text.to-float() + 1;
}
clicked-lower => {
self.lower-text = self.lower-text.to-float() + 1;
}
}
}
Consider this SlintPad demo (see comments):