Rectangle Not Transparent?

I wrote this code


If you look at the image you can see a green rectangle hiding the text beneath it, i want the rectangle to
be transparent so that the text is visible

The text is written on a text area.

What am i doing wrong? The code is placed inside the TextArea Open Event.

You tried RGB with alpha value?

Yes i tried that , with alpha value , but still it didnt do anything :frowning:

Someone please help me :cry: . I cant progress if i cant fix it.

Show us your code?

Are the colours for production? They are a bit intense.

I guess that’s because you’re on Windows. Xojo uses a pseudo transparency only there, so even if you would see the background, it would only be the background color and not the dynamic content.
See canvas transparency - again

The code is


Where “Me” is the text area
storeTExtString is the string “Hello World , Is it ok for you?” Multiple times
backColorRectangle is a rectangle that i dragged from the library and placed it on the text area
and made it transparent and gave it some color,

I also changed the alpha value in RGB but still no effect :frowning:

ok then i might need to find 2016 version :joy: :joy:

Depends on your intention. If you want to highlight a character, I’d rather use StyledText.

Yes i tried that but unfortunately , I cannot use that , because the text needs to be redrawn every time the user presses a button , its like Typing Test Software. So if i type “H” then the “H” will disappear and the next character needs to be highlighted , which if i use StyledText it takes time to redraw it whole.

Which is a fallacy i find in Xojo.

You did not reassign the modified StyledText to the TextArea’s StyledText property, did you?

yes i reassigned it with

textArea.StyledText.Text = "…"

because everytime the user presses a key which is checked with the first character say “H” from Hello World". So we need to remove the H from the textarea , and the only way to remove that i found to remove any character from a already present text in a textarea is to redraw the text in it.

Which works without any delay if i just say “Me.Text = " Some text”
But the delay occurs if i use StyledText , which needs to redraw it whole

Did you try:

backColorRectangle.FillColor = Color.RGB(0,255,100,127) // 127 = half transparent.

sadly yes :cry:

Ok on windows it’s not actual transparent but pseudo-tranparency.

Change you rectangle to a canvas and in the Paint Event try:

g.DrawingColor = Color.RGB(0,255,100,127) // 127 = half transparent.
g.FillRectangle 0,0,g.width,g.height

in the open event set the canvas to transparent or do that from within the IDE property editor.
check the result.

more info:
under Notes:

Canvases by default are transparent controls, which means the background color shows through. The Transparent property can be set (at design time or runtime) to turn this off/on as needed. An opaque Canvas flickers less on Windows and on Linux child controls on Canvases are clipped properly. On Mac, the Canvas is always transparent.


Controls placed behind a Canvas, regardless of the Transparent setting, will not be visible through the Canvas.

As you can read, controls will not show trough a canvas transparency. Keep in mind (on Windows)

1 Like

I see the problem, although I think I do not get the idea behind it fully.
Yes, redrawing a StyledText takes some time. And you are right, Windows graphics are not as well supported as macOS graphics in Xojo.
In that case – would just using the normal text highlight help? TextArea offers a lot of methods to influence the selection which should redraw much faster than StyledText.

1 Like

Yes i understand you point. But its just that i want to highlight only one character in the textarea which is not possible without styledText ,…

I wish i had the option of uploading a video so i could demonstrate the project. Anyways i will try to find out other ways to solve it Thanks :slight_smile:

Ok thanks let me try that :100:

sadly bro , its not working. Anyways thanks for trying. I will see what i can do :+1:

1 Like

On windows it may be best to draw the entire thing in a canvas, you can then draw the overlay rectangle in the canvas paint event over your text (which you draw in the pain event). In the canvas, all drawed elements can have transparency since it’s known what’s drawn.