wxMessageBox and wxMessageDialog - go behind the dialog 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

wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by deepti »

Hi All,

I have to fix this issue urgently for a code freeze, and something annoying has cropped up on Mac again.

Both wxMessageBox and wxMessageDialog go behind a modeless dialog. This issue is only on Mac.
Both the following ones dont work. The dialog which is displaying the message box is modeless. It works fine for Modal dialogs.

Code: Select all

wxMessageBox("Please note Time Active Controls will not be active in Document Edit Only Mode", "Information", wxICON_INFORMATION | wxOK);

Code: Select all

wxMessageDialog* msgDlg = new wxMessageDialog(this, "Please note Time Active Controls will not be active in Document Edit Only Mode", "Information", wxOK| wxICON_INFORMATION);

msgDlg->ShowModal();
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by PB »

Which wxWidgets version are you using?

I am not using OSX but I do remember a couple of issues with modal dialogs like this being reported, they may have been fixed in the master branch...
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by deepti »

i am using 3.1.0 version of wxWidgets. Is there any other way of achieving the same action as a message box? I need to fix this in the next couple of hours maximum :(

And this issue is seen only in modeless dialogs...not modal.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by doublemax »

I can't test under OSX myself. Things i would try:

If you know which dialog is open at that moment, use that window as parent for wxMessageDialog / wxMessageBox.

Use wxGenericMessageDialog instead of wxMessageDialog

Use SetWindowStyleFlag to add the wxSTAY_ON_TOP style flag after creating. (I don't think passing this into the style parameter will work.)


[Even if i sound like a broken record: Dialogs should always be modal, if you want something non-modal, use wxFrame. I know officially both things are supported, but i always see people having problems with modeless dialogs.]
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by deepti »

Thanks a lot for your reply.
I've already set the parent of the message dialog to the dialog invoking it, still doesnt work.

wxSTAY_ON_TOP is not implemented for OSX, as per the documentation.
[Even if i sound like a broken record: Dialogs should always be modal, if you want something non-modal, use wxFrame. I know officially both things are supported, but i always see people having problems with modeless dialogs.]
Will keep this in mind for the next time. But that dialog has been around for a long time now, so cant change it easily.
Use wxGenericMessageDialog instead of wxMessageDialog
Dont think it might help, but will give it a shot still.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by doublemax »

Can you hide the dialog and show afterwards as a temporary solution?

BTW: Does the messagebox/dialog come to the front when you click it?
Use the source, Luke!
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by deepti »

BTW: Does the messagebox/dialog come to the front when you click it?
Yes it does..

So, i made the dialog Modal and it works. It was modeless because there was no need for it to be modal. But, just to solve this issue, i made it modal :-|
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Post by PB »

deepti wrote:And this issue is seen only in modeless dialogs...not modal.
I meant wxMessageDialog which I assumed being modal. As I wrote above, IIRC the issues were with modal dialogs being displayed with a modeless dialog open. I think those issues can be easily found on wx-dev.

BTW, generally speaking I do not see advantage of using wxWidgets 3.1 over 3.1.1 or even master.
Post Reply