Ben,

But then how does this work ?

| point |
point := 1@2.
point inspect.
[ 5 seconds asDelay wait.
  point setX: 10 setY: 20 ] fork. 

You can see the inspector change its printString, without 
ValueHolders>>contents: being involved, just a direct instance variable 
assignment.

Sven

On 21 Mar 2013, at 11:41, Benjamin <[email protected]> wrote:

> For this kind of situation, my solution is to use a valueHolder
> 
> instead of storing your string directly in an inst var, store it into the 
> value holder
> 
> initialize
>       string := '' asValueHolder
> 
> string: aString
>       string contents: aString
> 
> string
>       ^ string contents
> 
> And then what you can do in your initialise is 
> 
> string whenChangedDo: [:newValue | self label contents: newValue ]
> 
> Something like this should work ^^
> 
> 
> The other solution (which is baaad, but can still be seen) is to have a step 
> method refreshing the Morph.
> But this is really not efficient
> 
> Hope it helps,
> Ben
> 
> On Mar 21, 2013, at 11:24 AM, MartinW <[email protected]> wrote:
> 
>> I asked the same question on Stackoverflow
>> (http://stackoverflow.com/questions/15534305/how-to-bind-a-labelmorph-textmorph-to-a-variable-so-that-the-morph-reflects-chan)
>> but as i do not know how much the audiences overlap i hope you do not mind
>> if i repeat it here:
>> 
>> How to bind a LabelMorph/TextMorph to a variable so that the Morph reflects
>> changes of the variable?
>> 
>> - I have an object with a variable containing a String.
>> - I have a window containing a LabelMorph/TextMorph (or some other Morph
>> that displays Text?).
>> How do i bind the LabelMorph/TextMorph to the variable, so that the label
>> updates when the String in the variable changes?
>> 
>> - classic Smalltalk-80 dependent/change/update mechanism?
>> - Pharo Announcement framework?
>> - something different??
>> How would i do this? Which Morph should i use?
>> 
>> Martin.
>> 
>> 
>> 
>> --
>> View this message in context: 
>> http://forum.world.st/How-can-my-Morph-reflect-changes-in-the-object-it-displays-tp4677629.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>> 
> 


Reply via email to