Totally confused about transparency in containers

If I create a container like this (on my Mac) …

and it HAS background color and is NOT transparent - 50% Opacity - something else should appear than this:

Or did I do something wrong? Not one line of code and it does not do what is expected, at least for me.

Any idea (except opening a feedback ticket)? Thanks a lot!

Maybe, maybe not. If Transparency = not opaque, then you’d need to select “Transparent” in the inspector as this would tell the macOS that the containercontrol is to allow transparency. Otherwise there are (minor) performance benefits to disabling "Transparent’.

I get the exact same result with transparency switched on … ? :confused:

Background colors in containers are fiddly. I set the background color in every container and in the window to the same color.

Xojo and transparency are not good friends. I had many visual artifacts after 2016r3 because it lost many transparency capabilities in Windows after that version. Xojo even says to not trust in their “composer” for transparency, because it flattens images to some background that sometimes it disagrees with the designer… Probably your case. Open a FB case and put this simple sample there… Let’s see what William will report back… or fix.

you MUST also set the background color and transparant in the IDE on the window (editor) where the container is on. Otherwise it will not honor it’s defined values (in the container editor) since the Inspector behaviour sets it back to the defaults (when dropped on a window or embedwithin).

I tried it out - the container does not change it’s color to anything else than white.

And NO, it is not possible to set transparency on the main window - Input:

Output:

I wonder what any new customer will think about that. It is inconsistent and no way out yet for me. My app is ready to market - but I can and will not deliver such an interface.

Any help is very much appreciated! Thank you all!

btw: I have a similar ticket open:

Transparency not working with Windows and Mac OS

At this time my App was not yet ready. But now it is. And I want to start. This is the only open issue now.

did you try the gear in the inspector?

That’s a very odd issue to have as last issue. Why not set the background color of the container to the same one that the window has?

Can you make an example for testing?

What happens when you use the container’s paint event for the background color instead of backgroundcolor?

I made a containercontrol, threw some controls on it. Then I added the container to the window and gave the window a backgroundcolor:

Container with a custom Paint event handler for the background embedded in a colored window.

What I see here in Windows is the losing of the transparency info, and the real color without transparency being fused with the background color, so…

In IDE we see the transparency

But at Runtime, as things are flattened to opaque colors, the yellow square is covered, and the blue one is trimmed by the opaque (expected transparent) container.

I do expect similar results for Mac.

Not fully. Xojo’s Windows framework does not really support transparency (I wonder if that could be changed by using the WS_EX_LAYERED flag when creating a control), whereby macOS does.

I wonder if the background color property on a container is supposed to work anyway, or if it could be fixed in Xojo‘s framework. Sadly Xojo (in former times) decided to make a ContainerControl a Window subclass, probably because it needs to have a free floating container in its IDE editor and that was based on a window.
Technically, a container is a NSView on macOS instead, not a NSWindow. A NSView does not own a background color property. Or rather indirectly: It must be a layer-backed window, and its optional CALayer has a backgroundcolor property.

So my guess is either this container’s backgroundcolor property is just a part of the virtual window in the IDE and was forgotten to be included as a Layer property (or was never intended to be used and should be hidden in the IDE), or Xojo forgot to set the wantsLayer property when creating the view to embed as a container in runtime.

Ok, it must be something more on the latter.
@Michael_Dettmer Derk’s advice works. When you use the Opening event of the container with something like

Me.HasBackgroundColor = True
me.BackgroundColor = Color.White // Or whatever

you will see the chosen background color.

1 Like

As the Xojo IDE is said as written in Xojo, it’s interesting to see that they can use it for their own purposes, as we see in the layout editor, but not for users at runtime.

image

the suggestion was about setting the transparency of the container inserted in the window

This is what I did and it did not work.

Wow, this seems to help. Thank you Derk and Ulrich, I will try to use that in the fifty places I am using transparency now … and thank you Rick for your thoughts. It appears that the (nice) IDE shows something which is not reflected in Mac and Windows Apps finally without additional code. Again this makes me think about new users and about quality (which is the degree of how something fulfills the expectations).

Anyhow - again a great community - thank you all :grinning:

2 Likes