Page 1 of 1

Some problems with wx 3.1.2 and OSX "Mojave"

Posted: Tue May 28, 2019 2:16 pm
by Mark Miles
Hi everybody.
I have recently "ported" one of my wx Projects that I originally made in 2014 with version 2.8 to the latest 3.1.2 and had to apply a whole lot of adaptations, but eventually got it to work nicely in Windows 7 (still haven't tested with Win10, tho).

The problem is on the Mac. D'oh!

The program compiles and runs, but here's a few issues:

1. all wxStaticBitmap elements to which I have Connected an event handler do not respond to mouse clicks. Here's an example:

Code: Select all

bmpCover = new wxStaticBitmap(this, ID_LOGO_BITMAP, Logo_png_to_wx_bitmap(), wxPoint(270, 10), wxDefaultSize, 0 );
bmpCover->Connect( wxEVT_LEFT_DOWN, wxCommandEventHandler( MainWindow::OnMenuAbout), NULL, this );
2. the text inside some widgets (mostly comboboxes) uses the same color as the foreground color, so if I set a light grey foreground color, it's barely readable if the combobox' background is white. Under Windows, the text in the comboboxes uses a different color than what I set as a foreground color for the frame.

So, my questions are:
1. How can I have a wxStaticBitmap that can respond to mouse clicks in OSX 10.14 (like it does in Windows and used to do as long as I used wx2.8)?
2. Can I specify two different foreground colors, one for the frame and one for each combobox?

Thanks in advance.

Re: Some problems with wx 3.1.2 and OSX "Mojave"

Posted: Tue May 28, 2019 2:52 pm
by Mark Miles
Ok, I just solved the combobox issue by writing a derived class that adds the SetForegroundColor in the constuctor, and also reduces the width by a few pixels. This is better than adding SetForegroundColor() to each and every combobox I have in my code (there are many!).

Code: Select all

class wxMyComboBox: public wxComboBox
{
public:
	wxMyComboBox(wxWindow *parent, wxWindowID id, const wxString &value = wxEmptyString, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, int n = 0, const wxString choices[] = (const wxString *)NULL, long style = 0, const wxValidator &validator = wxDefaultValidator, const wxString &name = wxComboBoxNameStr) :
		wxComboBox(parent, id, value, pos, size, n, choices, style, validator, name)
	{
		//SetBackgroundColour(*wxWHITE);
		SetForegroundColour(*wxBLACK);
		SetSize(size.GetWidth() - 2, size.GetHeight());
	}

	wxMyComboBox(wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style = 0, const wxValidator &validator = wxDefaultValidator, const wxString &name = wxComboBoxNameStr) :
		wxComboBox(parent, id, value, pos, size, choices, style, validator, name)
	{
		//SetBackgroundColour(*wxWHITE);
		SetForegroundColour(*wxBLACK);
		SetSize(size.GetWidth() - 2, size.GetHeight());
	}
};
Maybe I should write a similar derived class for the wxStaticBitmap to find a way to attach the event listener to it.

Re: Some problems with wx 3.1.2 and OSX "Mojave"

Posted: Tue May 28, 2019 2:59 pm
by doublemax
FWIW, i highly suggest not to change the default color of any GUI element. Especially under OSX.

Re: Some problems with wx 3.1.2 and OSX "Mojave"

Posted: Tue May 28, 2019 3:18 pm
by Mark Miles
doublemax wrote: Tue May 28, 2019 2:59 pm FWIW, i highly suggest not to change the default color of any GUI element. Especially under OSX.
Ok, thanks for the suggestion. But this unfortunately doesn't help me solve my problem.

The comboboxes under Mojave have a white background. My windows have a dark gray background and I set a light gray text color, which OSX also uses for the comboboxes, and results in being invisible on the white background. What's a better method to tell the comboboxes not to use the same foreground color set for the parent window?