wxDialog is displayed in the background only on Mac

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
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

wxDialog is displayed in the background only on Mac

Post 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++"
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDialog is displayed in the background only on Mac

Post 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
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxDialog is displayed in the background only on Mac

Post 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 :(
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxDialog is displayed in the background only on Mac

Post 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?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxDialog is displayed in the background only on Mac

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxDialog is displayed in the background only on Mac

Post 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..
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post 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.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxDialog is displayed in the background only on Mac

Post 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
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDialog is displayed in the background only on Mac

Post by ONEEYEMAN »

Hi,
So what is your code does differently from the taskbar sample?

Thank you.
Post Reply