I have a slider and want to change its value in some function. I tried with something like this:

(builder componentAt: #SliderR) widget model setValue: 124.

but it doesn't work. (value has changed but the marker remains in the same position).

有帮助吗?

解决方案

Try value: instead of setValue:

The incantation to access this ValueHolder seems quite long and fragile. Be sure to wrap such code under a clear message selector. Or maybe think of sharing this state in an instance variable of your application...

其他提示

Typically you would add the slider to your canvas in the UIPainter, then enter an aspect name for it in the GUI Painter Tool Window. The second button in that window's toolbar is called "Define". Click there to create a method that returns a ValueHolder with the slider's value. You can then use #value: to change the ValueHolder's value at runtime and it will update the slider's value as well as redraw it.

For some background: ValueHolders hold a value and other objects can register as dependents to it to be notified when the value changes. That's what the UI does, so that you can update the ValueHolder and the UI will automatically update itself.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top