Newbie Q: SimpleSliderMorph

Bilal Ahmed bilal at dgp.toronto.edu
Thu Jul 24 13:38:10 UTC 2003


Hi Ned, 

> How are you building the application? In Smalltalk or in eToys?
Smalltalk. 

> > - Is it possible to somehow add useful labels to the morph like
> > adding the minimum value, maximum value, and the current selected
> > value (so say, 0 on one end, 10 on the other, and a 5 in the middle
> > if thats the location of the slider button);
> 
> Morphs are so easy to aggregate that it's probably better to just 
> throw the appropriate label morphs together in the parent morph and 
> hook them to your model.
If I choose to add a StringMorph that simply displays this information, 
how do I ensure it gets updated whenever the slider is moved? It seems 
like I should be using UpdatingStringMorph, but that doesn't seem to work 
for me. 

What I have presently is 
levelSlider _ SimpleSliderMorph new color: (Color lightBlue);
	extent: 40 @ 20;
	target: self;
	actionSelector: #value:;
	adjustToValue: self value.		

That updates the instance variable value upon moving the slider. 

What I've tried with respect to UpdatingStringMorph is 
	valueString _ UpdatingStringMorph new.
	valueString contents: value printString. 
	self addMorphCentered: valueString. 

But it doesn't visually update the value when moving the slider (although 
internally it is). Is there perhaps an easier way to approach this? Again, 
all I'm hoping to do is show the value of value as it is updated.

Thanks for your help,

Regards,
Bilal



More information about the Squeak-dev mailing list