[Q] Updating a SystemWindow wrapping a StringHolder

Hannes Hirzel hirzel at spw.unizh.ch
Thu Feb 7 19:54:44 UTC 2002


On Thu, 7 Feb 2002, Ned Konz wrote:

> On Thursday 07 February 2002 01:25 am, Hannes Hirzel wrote:
> 
> > Where is the polymorphism here?
> >
> > Or is using a StringHolder not a good example?
> > But it is the base class of 39 other classes?

This gives the impression it implements basic functionality ;-).
 
> This is a sign that it might not do much by itself. There is no guarantee 
> that a specific class will have all the behavior you want.

Sure, but which one does implement updatable Workspace functionality?

> You could do this:
> 
> t _ TextMorph new
> 	string: 'this is my test' fontName: 'ComicPlain' size: 18.
> t openInWindow.
> t textColor: Color black.
> t contents: 'fred'
> 

This is a useful idiom in other contexts: it shows how to wrap a Morph
in a SystemWindow. 
When I assign the TextMorph a new content it updates the text instantly.

E.g. after 
t contents: 'Alan'.

The screen reflects the change.




However it's not what I would like to have.
1) The TextMorph does not fill the whole SystemWindow; there are visible
   borders around it.
2) The combination does not have Workspace functionality i.e. the
   possibility to execute code, to edit text in different fonts and
   to save it to a file.


Reasking the question:

How do I open a Workspace, assign it some initial content and 
later replace the content and make sure that the new content 
really shows up in the Workspace?


My remark was about polymorphism. I would expect the following to work:

sh _ (StringHolder new textContents: 'The initial content'
      withSqueakLineEndings; openLabel: 'MyLabel').

"...some other code ...."

sh textContents: 'my new content'.
sh changed.    "* <-- which message should be sent here?"



I would expect polymorphism in such an everday example to be at work.
But it's not. 


Cheers
Hannes Hirzel




More information about the Squeak-dev mailing list