How to prevent erasing the background of a custom control on macOS

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
fishnet37222
Experienced Solver
Experienced Solver
Posts: 74
Joined: Sat May 06, 2017 1:40 pm

How to prevent erasing the background of a custom control on macOS

Post by fishnet37222 »

I'm using wxWidgets 3.1.1 on macOS 10.14 with clang as the compiler.

I've created a custom control by subclassing wxWindow. I'm having a hard time getting rid of the white that's showing at the corners of the control.
2018-08-14_23-23-08.png
2018-08-14_23-23-08.png (1.9 KiB) Viewed 1181 times
Here are the first two lines of code in the constructor:

Code: Select all

wxWindow::SetBackgroundStyle(wxBG_STYLE_PAINT);
wxWindow::Create(parent, id, pos, size, style, name);
Is there any way to force macOS to not erase the background?
Dave F.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to prevent erasing the background of a custom control on macOS

Post by PB »

Sorry for the stupid question but have you tried to swap the two lines (and/or set the style directly with Create())?
fishnet37222
Experienced Solver
Experienced Solver
Posts: 74
Joined: Sat May 06, 2017 1:40 pm

Re: How to prevent erasing the background of a custom control on macOS

Post by fishnet37222 »

I do not see any overload of wxWindow::Create() that allows you to set the background style. When I swap the two lines, the background becomes black. I basically want the background to be transparent. However, when I call wxWindow::IsTransparentBackgroundSupported(), it returns false and the reason is "The system does not support background transparency." According to the documentation, macOS does support background transparency.
Dave F.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to prevent erasing the background of a custom control on macOS

Post by ONEEYEMAN »

Hi,
You probably should open a ticket on trac.wxwidgets.org about the transparency.
Modify the minimal sample by adding the appropriate call and see whether it still fails the detection. If it does - open a new ticket and attach the patch to the sample with you changes.

Thank you.
Post Reply