The slider only updates its label when its value is request through a *a
value*,'*b value* or *c value* message.
This should logically happen later in your script code, otherwise your
slider is not used and not needed.
You may have already read the* wave.st* script example.
You may add a :
* a inspect*
at the end of your script.
The slider is quick hack I wrote directly at DrGeoCanvas class to answer to
a request. It does pretty well it job so far.
I'm trying to be a simple script to experiment a few thing and I'm not
I just want a "slider", a point I can move on a segment and display it's
value. So far, it looks like this but the value is never displayed:
|canvas a b c|
canvas := DrGeoCanvas new.
a := canvas float: 0 at: -10@5 from: -10.0 to: 10.0 name: 'a' showValue:
b := canvas float: 0 at: -10@4 from: -10.0 to: 10.0 name: 'b' showValue:
c := canvas integer: 0 at: -10@3 from: -10.0 to: 10.0 name: 'c' showValue:
From Dr. Geo, looking at the source code of an integer slider, you can read label is updated only when the label value is requested (and updated too).
As it is Smalltalk land here, the slider code be adjusted if needed.
integer: aValue at: aPoint from: startValue to: endValue name: name showValue: isValueDisplay
"A valueslider ranging between startValue and endValue"
| segment mobile|
segment := self segment: aPoint to: aPoint + (170 / drgeo area scale @0).
mobile := self pointOnCurve: segment at: (aValue - startValue) / (endValue - startValue).
segment color: Color black; large.
mobile name: name;
color: Color black;
ifTrue: [[|value |
value := (mobile mathItem abscissa * ( endValue - startValue) + startValue) floor.
mobile rename: name, ' = ', value printString.
ifFalse: [[(mobile mathItem abscissa * ( endValue - startValue) + startValue) floor]]
Oups! Just saw the 2 brackets! So we're dealing with a block at this time, not a PointOnCurve! I was unable to halt the code inside the inner block!
If this is something (a slider segment with a point on it) that is often used, perhaps a slider object (that automatically updates itself on #move:) would be useful ? The slider could display min, max, current position, integer and determined "steps" size (e.g. steps of 0.25 along the segment for a float slider, or increments of 2 for integer segments).