<div dir="ltr">I did read that, in fact multiple times. I want to explain why I didn't interpret that as meaning that I shouldn't subclass BoxMorph. My thinking was that I DID want to implement a morph that can be displayed in a rectangular area. I didn't interpret it to mean I have to actually draw a rectangle. I assumed that I could just draw anything I want inside a rectangular area. So I drew a diagonal line and it didn't render.<div><br></div><div>Mariano suggested that I needed to send "<font face="monospace">super drawOn: canvas</font>" in my <font face="monospace">drawOn:</font> method. But I see now that what is really necessary to implement the following methods in my subclass or BoxMorph. This works.</div><div><br></div><div><font face="monospace">defaultExtent<br> ^`200@200`.<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">drawOn: aCanvas<br> aCanvas strokeWidth: 10 color: Color red do: [<br> aCanvas<br> moveTo: 0 @ 0;<br> lineTo: extent x @ extent y<br> ]<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">requiresVectorCanvas<br> ^true</font><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Dec 15, 2024 at 1:37 PM Juan Vuletich <<a href="mailto:juan@cuis.st">juan@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"><u></u>
<div bgcolor="#ffffff">
II'm pastiing the BoxMorph class comment for reference: <br>
<br>
Hierarchy for morphs that are rectangle like, and that occupy an
area that can be specified as a Rectangle. This means that, besides
being of rectangular shape, sides are aligned with local coordinate
axes. Including rectangles with rounded corners and such. The idea
is that the 'extent' ivar is all that's needed to establish our
dimensions and shape.<br>
Subclasses can add things like 'roundedCornerRadius' or such.<br>
Note: Answers false to #submorphsMightProtrude. If you need a box
like morph that can hold submorphs that can protrude if (i.e.
submorphs may extend beyond box bounds) DONT subclass from here.<br>
<br>
Hope this helps.<br>
<br>
On 12/15/2024 3:15 PM, Mark Volkmann via Cuis-dev wrote:
<blockquote type="cite">
<div dir="ltr">Thanks! I didn't consider doing that because I
didn't want the default light green background. And it seems
"super drawOn: aCanvas" isn't necessary when the superclass is
Morph or PlacedMorph.</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Dec 15, 2024 at
11:51 AM Mariano Montone <<a href="mailto:marianomontone@gmail.com" target="_blank">marianomontone@gmail.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">
<div>
<p>You are forgetting to call to super. Always consider that
when you are overriding a method.</p>
<p>It works. Look at screenshot attached.</p>
<div>El 15/12/24 a las 13:41, Mark Volkmann escribió:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">On Sun, Dec 15, 2024 at 7:37 AM Mariano
Montone via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>>
wrote:<br>
</div>
<div class="gmail_quote">
<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>
<p>Hi Mark,<br>
</p>
<div>El 14/12/24 a las 22:42, Mark Volkmann via
Cuis-dev escribió:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>I'm trying to understand what is
required to create a subclass of<span> </span><font face="monospace">BoxMorph</font>. I know
I need to implement the<span> </span><font face="monospace">drawOn:</font><span> </span>instance
method. And I believe that depending on
how I implement that, I need to implement
the<span> </span><font face="monospace">requiresVectorCanvas</font><span> </span>method
to return true.</div>
<div><br>
</div>
<div>Is anything else required? I think more
must be required, because I can't get a
basic example to work doing only those
things.</div>
</div>
</div>
</blockquote>
Have you tried browsing BoxMorph hierarchy and
looking at its subclasses?<br>
</div>
</blockquote>
<div><br>
</div>
<div>Yes. In particular I looked at <font face="monospace">ColoredBoxMorph</font>. That has
no class methods and 6 instance methods. The only
method that does something not directly related to
color is <font face="monospace">color:</font> which
sends <font face="monospace">#redrawNeeded</font>
to <font face="monospace">self</font> when the
color is changed. The <font face="monospace">initialize</font>
method sends <font face="monospace">#color:</font>
with the default color, so I thought perhaps when
subclassing <font face="monospace">BoxMorph</font>,
I need to send <font face="monospace">#redrawNeeded</font>.
I added the following instance method, but that
didn't help. </div>
<div><br>
</div>
<div><font face="monospace">initialize<br>
super initialize.<br>
self redrawNeeded</font><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>
<blockquote type="cite">
<div dir="ltr">
<div>
<div><br>
</div>
<div>I'd especially appreciate it if someone
can tell me how I could have determined
the answer on my own by looking at the
source. I tried to do that and failed.</div>
</div>
</div>
</blockquote>
<p>How is it failing? Perhaps attach example of
what you are trying to do ... it shouldn't be
much more than implementing a #drawOn: method
...</p>
</div>
</blockquote>
<div><br>
</div>
<div>If I create the class <font face="monospace">Try1</font>
as a subclass of <font face="monospace">Morph</font>,
add the following <font face="monospace">drawOn:</font>
method, and evaluate <font face="monospace">Try1</font>
new openInWorld in a workspace, it works as
expected.</div>
</div>
<div><br clear="all">
</div>
<div><font face="monospace">drawOn: aCanvas<br>
aCanvas class name print.<br>
aCanvas strokeWidth: 10 color: Color red do: [<br>
aCanvas<br>
moveTo: 100 @ 100;<br>
lineTo: 200 @ 200<br>
].</font><br>
</div>
<div><br>
</div>
<div>If I create the class <font face="monospace">Try2</font>
ais a subclass or <font face="monospace">PlacedMorph</font>,
add the same <font face="monospace">drawOn:</font>
method, and evaluate <font face="monospace">Try2 new
openInWorld</font> in a workspace, it also works.</div>
<div><br>
</div>
<div>But if I create the class <font face="monospace">Try3</font> as
a subclass of <font face="monospace">BoxMorph</font>,
add the same <font face="monospace">drawOn:</font>
method, and evaluate <font face="monospace">Try3 new
openInWorld</font> in a workspace, it does not work.
I get the error <span style="font-family:monospace">"MessageNotUnderstood:
HybridCanvas>>strokeWidth:color:do:"</span><font face="arial, sans-serif">. I understand that is
because </font><font face="monospace">BoxMorph</font><font face="arial, sans-serif"> u</font>ses <font face="monospace">HybridCanvas</font> by default
instead of <font face="monospace">VectorCanvas</font>,
so I added the instance method <font face="monospace">requiresVectorCanvas</font>
which returns <font face="monospace">true</font>.
That eliminates the eror, but doesn't result in
rendering anything. So it's not clear to me what I'm
missing in my <font face="monospace">Try3</font>
class.</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>
</div>
</blockquote>
</div>
</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>
</blockquote>
<br>
<br>
<pre cols="72">--
Juan Vuletich
<a href="http://cuis.st" target="_blank">cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" target="_blank">patents.justia.com/inventor/juan-manuel-vuletich</a>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" target="_blank">linkedin.com/in/juan-vuletich-75611b3</a>
<a href="http://twitter.com/JuanVuletich" target="_blank">twitter.com/JuanVuletich</a></pre>
</div>
</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>