Transparent Canvas not transparent

I am currently working on a TextField made of a Canvas, which looks nearly the same on OS X and Windows.

On OS X El Capitan 10.11.1:


On Windows 7:

If you take a close look at the above images, you will discover that on OS X, the left and right edges of the Canvas is not transparent.

In Xojo 2015 R3 i use the following settings for the Canvas:

What did i forgot to do to make the OS X Canvas really transparent in areas in which i did not Paint anything?

Thank you. :slight_smile:

[quote=225666:@Sascha S]What did i forgot to do to make the OS X Canvas really transparent in areas in which i did not Paint anything?
[/quote]

It looks as if you are doing some grey fillrect over the canvas before drawing the round rectangle. What is your code in Paint ?

Try to turn off doublebuffer.

You are right. That’s it. Indeed double buffer is not transparent. And it is quite unnecessary on Mac.

But wouldn’t this lead to flicker on Windows?

I am just drawing a filled RoundedRectangle + a Rectangle for the border

I would use something like :

Canvas1.DoubleBuffer = TargetWin32

[code] g.AntiAlias = True

#If TargetWin32 Then

Me.DoubleBuffer = True

g.ForeColor = &cB3B3B300
g.DrawRoundRect(0,0,g.Width,g.Height,3,3)
g.ForeColor = myBackgroundColor
g.FillRoundRect(1,1,g.Width-2,g.Height-2,3,3)

#Else

Me.DoubleBuffer = False

g.ForeColor = &cB3B3B300
g.DrawRoundRect(0,0,g.Width,g.Height,20,20)
g.ForeColor = &cE6E6E600
g.DrawRoundRect(1,1,g.Width-2,g.Height-2,20,20)
g.ForeColor = myBackgroundColor
g.FillRoundRect(2,2,g.Width-4,g.Height-4,20,20)

#EndIf

If MouseIsOverMagnifyingGlas Then

g.DrawPicture(searchfield__glow_16, 3, 3)

Else

g.DrawPicture(searchfield_16, 3, 3)

End If

If SearchField.Text.Len > 0 Then

g.DrawPicture(close_16_flat, g.Width-19, 3)

End If[/code]

[quote=225678:@Sascha S][code] g.AntiAlias = True

#If TargetWin32 Then

Me.DoubleBuffer = True

g.ForeColor = &cB3B3B300
g.DrawRoundRect(0,0,g.Width,g.Height,3,3)
g.ForeColor = myBackgroundColor
g.FillRoundRect(1,1,g.Width-2,g.Height-2,3,3)

#Else

Me.DoubleBuffer = False

g.ForeColor = &cB3B3B300
g.DrawRoundRect(0,0,g.Width,g.Height,20,20)
g.ForeColor = &cE6E6E600
g.DrawRoundRect(1,1,g.Width-2,g.Height-2,20,20)
g.ForeColor = myBackgroundColor
g.FillRoundRect(2,2,g.Width-4,g.Height-4,20,20)

#EndIf

If MouseIsOverMagnifyingGlas Then

g.DrawPicture(searchfield__glow_16, 3, 3)

Else

g.DrawPicture(searchfield_16, 3, 3)

End If

If SearchField.Text.Len > 0 Then

g.DrawPicture(close_16_flat, g.Width-19, 3)

End If[/code][/quote]

That should work just fine.

No, it doesn’t. Because the DoubleBuffer Setting needs to be in the open Event. I removed the DoubleBuffer Lines from the Paint event and moved them into the Open Event of the Canvas:

[code] #If TargetWin32 Then

Me.DoubleBuffer = True

#Else

Me.DoubleBuffer = False

#EndIf
[/code]

This is the result:

Thank you @Marco Hof and @Michel Bujardet thumb-up

[code]#If TargetWin32 Then

Me.DoubleBuffer = True

#Else

Me.DoubleBuffer = False

#EndIf[/code]

Sascha, all this can be replaced by :

Me.DoubleBuffer = TargetWin32

No need for an #If #Else #EndIf…

Thank you :wink: