<div dir="ltr">I must be doing a poor job of describing what I want to achieve.<div>I've boiled it down to the minimum code needed to demonstrate.</div><div>Here are the steps:<div><br></div><div>- create a subclass of <font face="monospace">Object</font></div><div><font face="monospace"><br></font></div><div>- add the following instance methods</div><div><br></div><div><font face="monospace">initialize<br> | tmm |<br> <br> tmm := TextModelMorph withText: '' :: acceptOnAny: true.<br> SystemWindow new addMorph: tmm; openInWorld.</font><br></div><div><br></div><div><font face="monospace">update: arg<br> 'update was called' print</font><br></div><div><br></div><div>What can I do in the <font face="monospace">initialize</font> method so <font face="monospace">update:</font> is called after every keystroke in the <font face="monospace">TextModelMorph</font>?</div></div><div>Here are two things I tried that do not work:</div><div><br></div><div><span style="font-family:monospace"> tmm model addDependent: self.</span></div><div><br style="font-family:monospace"><span style="font-family:monospace"> tmm model when: #actualContents send: #update: to: self.</span><br style="font-family:monospace"></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Mar 23, 2025 at 11:45 AM Weslleymberg Lisboa via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div dir="auto">TextModel generates some events. Browse senders of #changed: to see it. Maybe the event that #addDepedent: listens to is not the one you need.<br><br>Cuis use the Observer Pattern as a dependency mechanism (see [1]) so #addDependent: and #changed: are "simplifications" of #when:send:to: and #triggerEvent:with:<br><br>IMHO if what you need is to be notified of changes in the model, I'd use it directly instead of making TextModelMorph notify me.<br><br>1 - <<a href="https://github.com/nmingotti/The-Cuis-CookBook/wiki/The-Dependency-Mechanism--3" target="_blank">https://github.com/nmingotti/The-Cuis-CookBook/wiki/The-Dependency-Mechanism--3</a>></div><br><br><div class="gmail_quote"><div dir="auto">Em 23 de março de 2025 11:53:10 BRT, Mark Volkmann via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> escreveu:</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div dir="ltr">As far as I can tell,<span> </span><font face="monospace">TextModel</font><span> </span>morph does not send<span> </span><font face="monospace">#changed:</font><span> </span>every time its value changes, so that prevents me from listening for updates. I see that the <font face="monospace">TextModel</font><span> </span>method<span> </span><font face="monospace">actualContents:</font><span> </span>does send<span> </span><font face="monospace">#changed:</font>, but that is not invoked on every change to a<span> </span><font face="monospace">TextModelMorph</font><span> </span>even when it is configured with<span> </span><font face="monospace">acceptOnAny: true</font>.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 23, 2025 at 9:38 AM <<a href="mailto:ken.dickey@whidbey.com" target="_blank">ken.dickey@whidbey.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 2025-03-23 06:35, Mark Volkmann via Cuis-dev wrote:<br>
<br>
> ...<br>
> myTextModelMorph addDependent: self.<br>
..<br>
> <br>
> I have a few questions.<br>
> - Are there reasons why I should not want this ability?<br>
<br>
Generally, Morphs are Views and update to reflect changes in an <br>
underlying Model.<br>
<br>
A Morph can be a Model if sensible.<br>
<br>
> - Would it be better to listen for changes on the underlying TextModel?<br>
<br>
IMHO, yes.<br>
<br>
$0.02,<br>
-KenD<br>
</blockquote></div><div><br clear="all"></div><div><br></div></blockquote></div><div dir="auto"><br>--<br>Att.<br>Wéslleymberg Lisboa<br>Graduado em Sistemas de Informação<br>Docente no IFFluminense - Campus Itaboraí<br>Ex-Bolsista de IC do Núcleo de Computação Científica (NC2-IFF) - Projeto IFF Aerospace<br>Github: <a href="https://github.com/weslleymberg" target="_blank">https://github.com/weslleymberg</a><br>Tel.: +55 22 99931-2376</div></div>-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>