Page 1 of 1

wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 12:29 pm
by deepti
Hi,

I have a wxDialog instance (with parent set to NULL). On Show(), it ends up being displayed behind some other application windows that are open, and not shown in the front. This works perfectly on Windows.

Setting the flag to wx_STAY_ON_TOP will not be so useful, since there are other UI options and on click of these options, newer wxDialog instances need to be displayed on top of the first.

Please help!

1. wx version is 3.1.1 (issue is seen even on 3.1.0)
2. OS is Mac High Sierra 10.12
3. wx was configured using the following command:

./configure --disable-shared --enable-unicode --with-libjpeg=builtin --with-libpng=builtin --with-cocoa CXXFLAGS="-std=c++11 -stdlib=libc++ " OBJCXXFLAGS="-std=c++11 -stdlib=libc++" LDFLAGS="-stdlib=libc++"

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 1:36 pm
by doublemax
Have you built a wxWidgets app on OSX successfully before? If not, this is most likely the problem:
https://wiki.wxwidgets.org/WxMac-specif ... e_front.21

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 3:29 pm
by deepti
The Mac application has been existing for a while now, but the dialog popping behind issue has been there too, and no one really worked on it before!

So, this is what I tried in the OnInit() function:

ProcessSerialNumber psn = { 0, kCurrentProcess };
(void) TransformProcessType(&psn, kProcessTransformToForegroundApplication);

But still no luck :(

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 3:50 pm
by ONEEYEMAN
Hi,
I vaguely remember there was a post to wx ML about this and I thought Stefan fixed it.
Now to investigate it - is this with the custom dialog or the standard one?
Can you build the dialogs sample and check whether it works there?

Thank you.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 4:09 pm
by deepti
Hi,

It is a custom dialog derived from wxDialog.
Could you please point out the link to the dialogs sample you are referring to?
I am completely new to Mac, so it might take a while to try out this sample app.
Meanwhile, is there something else I could try?

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 4:23 pm
by ONEEYEMAN
Hi,
Download the source code of the library from https://www.wxwidgets.org/downloads/.
Unpack it, then go to samples/dialog.
Open the dialogs.cpp.

In order to build the sample, go to wxWidgets/buildMac/samples/dialog
Issue "make" command.
Do "open dialogs.app"

Thank you.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 5:15 pm
by deepti
Thanks a lot for the detailed post.
I tried out the sample dialogs app. It just opens up a simple dialog with minimise, maximise and close buttons. But does open up in the foreground.

In the case of our application, when it is opened, it creates an icon in the dock (similar to say Skype), and then on click of a drop-down option, the wxDialog instance is created and displayed (but in the background).

Please let me know if you need any other details.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 5:24 pm
by ONEEYEMAN
Hi,
Ok, so after you launch the sample, you can open all different types of dialogs including a standard ones.
And you are saying that all those dialolgs will be opened in the foreground?

Because the main frame that will be displayed when you run the sample is not a dialog. You can try to hit Ctrl+M to see a message box or check the "Dialogs" menu to see what kind of different dialogs can be opened.

Please play with the sample and see if you can reproduce the behaviour you describe.

Thank you.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 5:37 pm
by deepti
All the dialogs appear correctly in the sample dialogs app. They are all seen in the foreground.
Is it because they are being opened as menu items?
Whereas in my case, it is on right-click option of the tray icon/docked icon at the top..

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 6:12 pm
by ONEEYEMAN
Hi,
I don't know. Its quite possible.
Are you using wxTaskBar-related classes? Can you check if the taskbar sample work for you or if it has this functionality to open the dialog?

Thank you.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 6:31 pm
by ONEEYEMAN
Hi,
I don't know. Its quite possible.
Are you using wxTaskBar-related classes? Can you check if the taskbar sample work for you or if it has this functionality to open the dialog?
Another possibility is that the parent of the dialog is set to NULL.

Thank you.

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 6:47 pm
by deepti
Yes yes, the parent of the dialog is indeed NULL. Is it not supposed to be?

And i tried the taskbar sample too..it works fine. Even in this sample, the dialog's parent is set to NULL

Re: wxDialog is displayed in the background only on Mac

Posted: Thu Feb 07, 2019 7:56 pm
by ONEEYEMAN
Hi,
So what is your code does differently from the taskbar sample?

Thank you.