[Cuis-dev] dependency mechanism for TextModelMorph

Mark Volkmann r.mark.volkmann at gmail.com
Sun Mar 23 06:35:04 PDT 2025


I would like to be able to use the dependency mechanism to be notified
about changes to the value of a TextModelMorph. I've discovered that I can
get this if I add the following line to the acceptContents method of
InnerTextMorph after the variable accepted is set:

accepted class = TextModel ifTrue: [ owner changed: owner ].

In a class that creates a TextModelMorph I can then do this:

myTextModelMorph addDependent: self.

Then I can add an update: method to that class like this:

update: sender
    sender = myTextModelMorph ifTrue: [
        | value |
        value := sender model actualContents asString.
        'value is now ', value :: print
    ].

I have a few questions.
- Are there reasons why I should not want this ability?
- Is there a better way to achieve this that doesn't require modifying
InnerTextMorph?
- Would it be better to listen for changes on the underlying TextModel?
  I couldn't find a way to get that to work either without modifying that
class.

I attached a changeset in case the change to InnerTextMorph seems desirable.

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250323/2ba34d23/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7088-CuisCore-MarkVolkmann-2025Mar23-08h19m-rmv.001.cs.st
Type: application/octet-stream
Size: 1588 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250323/2ba34d23/attachment.obj>


More information about the Cuis-dev mailing list