Colour me beautiful OSX - Big Sur

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
SamCam
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Nov 30, 2020 2:23 pm

Colour me beautiful OSX - Big Sur

Post by SamCam »

Hi gang,

Running WxWidgets 3.0.5 on Big Sur + Xcode

I'm porting a basic application from MSW over to OSX and it's going well however I'm having a hard time matching the colouring properties I am achieving successfully in MSW.

I can see this topic has been covered before but I didn't quite find the answer I was looking for.

I really don't mind that this app wont match any OSX themes and design criteria. It's not for public release and doesn't need to be attractive to OSX users. Part of the functionality is to allow the text to be coloured.

Image
An image of the app in MSW as intended.

I can live without coloured buttons however the wxTextCtrl and wxListBox are more important.

So this doesn't quite work:

Code: Select all

txt0->SetForegroundColour({ 255,255,255 }); //Does not set Text colour
txt0->SetBackgroundColour({ 0,0,0 }); //Does set the BG colour to black. 
I read on the forum:

Code: Select all

//txt0->SetDefaultStyle(wxTextAttr({ 255,255,255 })); //Does not set Text colour
But this also doesn't seem to work.

Can this behaviour be overridden? If so, how?

Many thanks, loving wxWidgets otherwise!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Colour me beautiful OSX - Big Sur

Post by ONEEYEMAN »

Hi,
If you are on Big Sur, you should try with 3.1.4 or Git master.
There may be some fixes that are not available in 3.0.

If it works - great.
If not - it may be a bug in wxOSX and you may need to create a ticket on trac.

Thank you.
SamCam
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Nov 30, 2020 2:23 pm

Re: Colour me beautiful OSX - Big Sur

Post by SamCam »

Thanks, I updated to 3.1.4 and this came with some functionality for OSX in the form of wxTextAttr and the SetTextColour() and SetBackgroundColour() functions along with that.

The wxTextAttr isn't compatible with the wxListBox (as far as I can tell) so still some work for me to do there. Another unfortunate thing is that these functions don't seem to work in MSW.

Ho hum, I guess I was going to have to write some platform specific code at some point.

Can anyone recommend a way to change the text cursor colour at all? Now I've got my text back ground set to black OSX still has a black cursor, MSW changes it to white for me automatically....

Thanks for your suggestion. It's worth keeping up to date after all.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Colour me beautiful OSX - Big Sur

Post by ONEEYEMAN »

Hi,
Are you stuck with the wxListBox? Can you use wxListCtrl?
Build and run the listctrl sample and see how it works with the different colors there.

Also, try to build the text sample on both platforms and see if the text attribute (in your case colors) works there.

Thank you.
SamCam
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Nov 30, 2020 2:23 pm

Re: Colour me beautiful OSX - Big Sur

Post by SamCam »

Hey, I'll definitely look at wxListCtrl as an option, I hadn't realised that it was a thing! (Still much further down the rabbit hole for me to go.)

I ran up the textSamples as you suggest and they will be helpful. There are some differences between platforms but nothing major. I notice that the cursor colour seems stuck on OSX, MSW will apparently change it automatically depending on the BG color, nice.

Oddly, on OSX none of the menu options are accessible which is a shame, as the rich text editor in the example is useful for changing colours at runtime. Not sure if this is a bug, I've basically copied and pasted the .cpp file from github to make this run so it may be missing another important file.

Many thanks for these suggestions, I believe I'll be able to work through this and get the behaviour I'm looking for.

Images of how the text samples appear in MSW & OSX attached below.
Attachments
WxTextSampleMSW.PNG
WxTextSampleMSW.PNG (62.37 KiB) Viewed 1403 times
wxTextSample OSX.png
Post Reply