Page 1 of 1

wxMessageBox and wxMessageDialog - go behind the dialog only on Mac

Posted: Wed Sep 26, 2018 4:45 pm
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();

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

Posted: Wed Sep 26, 2018 4:52 pm
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...

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

Posted: Wed Sep 26, 2018 4:59 pm
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.

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

Posted: Wed Sep 26, 2018 6:43 pm
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.]

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

Posted: Wed Sep 26, 2018 6:48 pm
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.

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

Posted: Wed Sep 26, 2018 7:35 pm
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?

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

Posted: Wed Sep 26, 2018 7:59 pm
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 :-|

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

Posted: Thu Sep 27, 2018 5:52 am
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.