[Cuis-dev] LayoutMorph newColumn

Mark Volkmann r.mark.volkmann at gmail.com
Thu Aug 8 04:06:52 PDT 2024


On Wed, Aug 7, 2024 at 9:17 PM <ken.dickey at whidbey.com> wrote:

> On 2024-08-07 16:42, Mark Volkmann via Cuis-dev wrote:
>
> > I have a related question. I have a class that is a subclass of
> > LayoutMorph.
> > Where is the best place to configure the direction to be #vertical?
>
> Why does
>    LayoutMorph newColumn
> not work for you?
>

My class is a subclass of LayoutMorph, so I'm not sending a #new* message
to LayoutMorph directly. I'm sending #new to my own class.

What does stepping through with the debugger suggest?
>

I see what's happening now. "LayoutMorph new" (invoked by sending #new to
my subclass) sends #newRow which sends #initialize AND THEN #beRow.
So changes I make to direction in my subclass initialize method get
overridden by beRow.
This seems similar to the color: issue I had.
I can fix this by overriding new in my subclass like this:

new
    ^ super new beColumn

But the width of my subclass instance gets calculated based on laying out
the submorphs as a row and does not get adjusted down when it switches to a
column.
See the attached screenshot. What can I do to force it to recalculate the
width?
I tried the following in my new method, but this didn't fix it:

new
    | instance |
    instance := super new beColumn.
    instance refreshExtent.
    instance layoutSubmorphs.
    instance layoutNeeded: true.
    ^ instance

Side note: I see that the direction: method in LayoutMorph contains the
following:

self flag: #jmvVer. "Move to category #accessing"

Is there a reason not to do that now and remove that line?

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240808/f3c6ec36/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2024-08-08 at 5.58.00?AM.png
Type: image/png
Size: 15321 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240808/f3c6ec36/attachment-0001.png>


More information about the Cuis-dev mailing list