wxWidgets icon indicating copy to clipboard operation
wxWidgets copied to clipboard

MacOS: wxMessageDialog only shows error icon with Yes / No buttons

Open wouterbt opened this issue 1 year ago • 3 comments

On MacOS, wxMessageDialog uses a native dialog that shows the application icon. When used with the wxICON_ERROR style, an error icon (exclamation mark triangle) is displayed with the application icon, but only with the wxYES_NO style, not with the wxOK style. ok yes-no The expected behaviour is to always show the error icon when the wxICON_ERROR style is present. Although Apple GUI design guidelines suggest to use the caution symbol sparingly, they do not prohibit it in alerts with only an OK button.

Example code producing the issue:

#include <wx/wx.h>

class MyApp : public wxApp {
public:
    bool OnInit() {
        wxMessageDialog dlg1(NULL, "text", "Error", wxICON_ERROR | wxOK);
        dlg1.ShowModal();
        dlg1.Destroy();

        wxMessageDialog dlg2(NULL, "text", "Error", wxICON_ERROR | wxYES_NO);
        dlg2.ShowModal();
        dlg2.Destroy();

        return false;
    }
};

wxIMPLEMENT_APP(MyApp);

wouterbt avatar Jun 10 '24 14:06 wouterbt

This is due to this code here:

https://github.com/wxWidgets/wxWidgets/blob/7f5ca30e3eebbdb85222fbe329a5100b4da65804/src/osx/cocoa/msgdlg.mm#L39-L42

so it's done intentionally. @csomor I don't know if we/you want to change this?

vadz avatar Jun 10 '24 22:06 vadz

Yes it's done on purpose. The comment above these lines cited refers to the HIG. IMHO if it's something critical, then the user should be offered an option (Yes or No, Ok or cancel) to prevent the consequences, then it's critical, then it get's the icon.

That's following the guidelines in general and leads to the best platform impression in my view, avoiding the alert fatigue that comes with the overuse of these on other platforms, where these WARNING signs then tend to be clicked away by the user without even reading them properly, even if the would have been CRITICAL.

But I see that this situation is different insofar, as it's an error not a warning, so I'd change the code to always use critical if it is an error.

csomor avatar Jun 11 '24 06:06 csomor

I completely agree with the notion that the caution symbol should be used sparingly, as per the HIG. However, I think that should be the programmer's responsibility, and not be enforced by the GUI library. Furthermore, I do not think that having to make a choice (Yes / No) as opposed to only confirming the message (OK) should be the determining factor for whether or not to display the icon. I can think of instances where it is equally important that the user actually read the message before continuing their work, even if there is no choice to make.

So I agree that we should change the code and perhaps add a remark to the documentation of the wxICON_ERROR style urging the programmer to adhere to the HIG.

wouterbt avatar Jun 11 '24 07:06 wouterbt