- 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?
Depends on what you want to achieve. You might want to take a look at a way to do it with Glamour in a current Moose image. In a workspace, do-it:
That shows how to work with announcements on save. The earlier examples are a better way to start understanding how to work with Glamour (and because of the way the examplebrowser is build, the Magritte example doesn't update the list when it is nested):
That has several other examples that update on change.
Simplest is to use an updating String morph:
This will send #myLabel (or any other message) to self (or any other object) and display it.
This is a solution provided by Benjamin Van Ryseghem on the Pharo Mailinglist:
I tried this in a Workspace: