<div dir="ltr"><div dir="ltr">On Sat, Aug 10, 2024 at 12:18 PM <<a href="mailto:ken.dickey@whidbey.com">ken.dickey@whidbey.com</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">On 2024-08-09 17:54, Mark Volkmann via Cuis-dev wrote:<br>
<br>
> I want to add a morph as the first submorph in a LayoutMorph that <br>
> already has submorphs.<br>
> I thought the addMorphFront: method would do that, but it doesn't.<br>
<br>
No.  addMorph{,Front,Back}: work with Z-Order (drawn back to front), not <br>
morphPosition.<br>
<br>
Comments in the code indicate morphs are always added to the <br>
right/bottom.<br>
<br>
As LayoutMorphs are typically setup in code when a window/panel is <br>
initialized, no one has asked for a convenience function to specify <br>
where you want a submorph in left-to-right/top-to-bottom spatial order.<br>
<br>
In writing code to do this you should learn about how submorphs are <br>
managed.<br></blockquote><div><br></div><div>Okay, I did a deeper dive into the code and discovered the following:</div><div><br></div><div>LayoutMorph addMorph: calls</div><div>LayoutMorph addMorphFront: which calls</div><div>Morph addMorphFront: which calls</div><div>Morph privateAddMorph:atIndex: (with 1 for atIndex:) which calls</div><div>Morph privateAddMorph:atIndex:position: (with nil for position:)</div><div>This replaces the submorphs array with a new array where the morph being added is added at the beginning of the new array.</div><div>It's not clear to me yet when adding it there is better than adding it at the end.</div><div><br></div><div>For a vertical LayoutMorph, LayoutMorph layoutSubmorphs calls LayoutMorph layoutSubmorphsVerticallyIn:.</div><div>That iterates over the visible morphs in reverse order (from first added to last added)</div><div>and assigns a position to each visible submorph.</div><div>Here is where I don't get the claim that addMorphFront and addMorphBack are all about Z-order.</div><div>From this code, for a vertical LayoutMorph, those methods seem to be all about Y-order</div><div>since they control the order of the submorphs array</div><div>and that is used to assign y coordinates to each of the submorphs.</div><div><br></div><div>The main thing I learned is that if you want to add a morph to a vertical LayoutMorph</div><div>and you want it to appear at the beginning of the vertical list of morphs,</div><div>you need to use addMorphBack:.</div><div>That last bit is what I was looking for all along.</div></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>