Initialization and Opening event sequence for DesktopContainer and Controls

Inside of a DesktopContainer, I would like to create a Dictionary that can be used by several of the container’s Controls in their Opening events. Is there a recommended place, a BeforeEverythingEvent inside the container to initialize the Dictionary? I tried the DesktopContainer’s Opening event, but it happens after the Controls’ Opening events. Color_dictionary is a property of the DesktopContainer.

Workarounds:
I settled on making one Control initialize Color_dictionary in its Opening event, but that is no guarantee it will always be the first Control to fire.
Or, every event that needs the Dictionary could just call the same method to initialize the Dictionary…

This may help:

2 Likes

You can add a Constructor to the DesktopContainer and initialize Color_dictionary there. That fires before any of the controls are created.

2 Likes

@Tim_Hare

Where do we find the documentation for the event firing order?

and

https://documentation.xojo.com/api/user_interface/desktop/desktopwindow.html#description
In that page, follow Constructor and you will find a bit of info… (scarse).

Thanks, A Constructor looks like the thing to use, although the docs seem to warn us off of using them.

if you share this Color_dictionary why not put it into a module?
does each container have a own list of possible colors?

add in the events System.DebugLog CurrentMethodName, you will see the order of events at messages.

maybe you could define a ReQuestColorList event.

1 Like

That’s a good idea. At this point the Container is a basic text editing area that can be dropped into a window. The color set is just the named color Xojo constants like Color.Red, but it could eventually be made to substitute its default colors with a set of colors that the app it’s living in sends to it.

i made similar and used a subclassed textarea for more features and context menu
because i need multiple textareas and reuse it.
a sub class is very useful because we can add methods and propertys to it.
i frequently use a sub class also for canvas or database.