MessageDialog - how to set Cancel button as Default button?

It appears that MessageDialog has a usability flaw: It’s not possible to make the second button the default button, or am I missing something?

Note:

For “dangerous” confirmation dialog such as one would show when something might get accidentally deleted, the Cancel and not the OK button should be made the default button so that the user does not accidentally press the Return key and thereby performs an unintended destructive operation.

This is, BTW, often done wrong by switching the positions of the button. For example, this is even worse (example for Mac, not Windows - on Windows the buttons order is to be reversed):

THIS IS WRONG (on Macs):

Do you want to delete this data?
[Delete] [Cancel]

The above example is bad because a trained user has learned that any dialog he doesn’t expect has the Cancel button in the second-to-left position. So, if he wants to cancel something unexpected, he might BLINDLY click on that 2nd button - and if you make that the Delete button, you’ve screwed him. That behavior is called muscle memory and you should not try to be smarter by doing what’s shown above.

On the Mac, a dialog should ALWAYS have the right button be the one that continues the operation and the second button (on its left) be the one that cancels it. If you don’t follow this, you might upset your customers because you’d also have violated Apple’s UI guidelines. (Mind you, even Apple programs get this wrong sometimes, but get it usually fixed once I point that out via a bug report.)

THIS IS CORRECT (on Macs):

Do you want to delete this data?
[Cancel] [Delete]

Now, the only problem with this correct order is Xojo’s MessageDialog, because it won’t let me make the Cancel button the default button so that it appears highlighed (blue) and reacts to the Return and Enter keys. And that really sucks as this encourages Xojo programmers to reorder the buttons, thereby violating UI guidelines and causing trouble for users.

You can change the default property for the MessageDialogButtons in a MessageDialog:

[code]dim msgd as new MessageDialog
msgd.Message=“test”

msgd.ActionButton.Caption=“action”
msgd.ActionButton.Default=false

msgd.CancelButton.Visible=true
msgd.CancelButton.Caption=“cancel”
msgd.CancelButton.Default=true

dim msgb as MessageDialogButton
msgb=msgd.ShowModal

select case msgb
case msgd.ActionButton
case msgd.CancelButton
case msgd.AlternateActionButton
end select[/code]

I just tested and it works fine here.

Thanks, Tom!

I had looked at the docs for http://documentation.xojo.com/index.php/MessageDialogButton but obviously was blind to see the Default property there.

Whew, thanks!

[quote=200289:@Thomas Tempelmann]THIS IS CORRECT (on Macs):
Do you want to delete this data?
[Cancel] [Delete][/quote]
As per the HIG this is not true. If you have a default button (which is not mandatory), it has to be the right most button, and the action button must be the right most button too:

*[Cancel]* [Delete] // not valid [Cancel] *[Delete]* // valid [Cancel] [Delete] // valid

Why not do this ?

Make Action “Cancel”, hide the cancel button and add alternate “Proceed” ( or “OK”) …

Alternatively, you could have OK do nothing, keep Cancel, and have Alternate do Proceed. Cumbersome but conformant to the HIG dogma outlined by Eli.

This operation is dangerous. You should rather not.
It can severely bezerk the contraption.
[Cancel] [Proceed anyway] [OK]

[quote=200297:@Eli Ott]As per the HIG this is not true. If you have a default button (which is not mandatory), it has to be the right most button, and the action button must be the right most button too:
[/quote]

I love HIG, but if they go against the safety of the user, I would tend to prefer the three laws of Robotics :wink:

Michel, I explained why your example is bad. Read about muscle memory (well, or at least what I mean is similar to that effect).

Eli, see my article on this topic: http://www.tempel.org/DialogButtonPlacement

Unfortunately, Apple has (again) redesigned their website and the link to the HIG that showed that I am right has gone bad.
I’ll see that I find the new link again.

Here are a few quotes from the current Apple HIG:

“The rightmost button in the dialog, the action button, confirms the alert message text. The action button is usually, but not always, the default button” – that’s for you, @Michel Bujardet

“Use a default button only if the user’s most likely action is harmless. Make the default button represent the action that the user is most likely to perform if that action isn’t potentially dangerous” - note: Default button is the one that reacts to Return and is drawn in blue on Macs.

And finally:

“Don’t use a default button if the user’s most likely action is dangerous. An example of a dangerous action is one that causes a loss of user data. […] You can consider using a safe default button, such as Cancel, or not using a default button at all.”

So, Eli, how come you claim that what I wrote is wrong when the HIG clearly agrees with me? To me, this sounds that you haven’t read the HIG when in fact you claim you have?! Or have you read the Window HIG? I wonder if they contradict Apple’s. Would be nice to have that clarified.

[quote=200303:@Thomas Tempelmann]Michel, I explained why your example is bad. Read about muscle memory (well, or at least what I mean is similar to that effect).

Eli, see my article on this topic: http://www.tempel.org/DialogButtonPlacement

Unfortunately, Apple has (again) redesigned their website and the link to the HIG that showed that I am right has gone bad.
I’ll see that I find the new link again.[/quote]

I was just suggesting. In the end, anyone of us can do whatever he wants. Including “wrong”. To me “wrong” is when the user **** up his work because of an ill conceived dialog. If conformant to the HIG, a dialog does harm, it is evil.

Once again, I rather go first law of Robotics …

As for your need to have a default Cancel button, seems to me it is just as easy as using a Modal window designed as a dialog. But once again, you may get excommunicated by the HIG’s ayatollahs…

In the end, I rather make sure my users do not get in trouble because of my programs, rather than follow blindly the self appointed preachers of the HIG. I rather have less support requests than criticism from lesson givers.

I understand it that way:

[Delete]             [Cancel] *[Do Not Delete]*

Well, but exactly that happens if you do not follow the HIG: I, for instance, had it happen that I accidentally hit a key that led to Entourage asking me if I wanted to delete all mails in a folder. I panicked and clicked on the button where ALWAYS the Cancel button should be - the second one to the left. But since the MS engineer thought to be smarter that the HIG, he placed the “delete” button there, and I lost a whole lot of emails.

The NORM is that the second-to-left button - on Macs - shall be the Cancel button. And most dialogs do this. If you place a destructive button there, you’ll likely cause grief to some users. Don’t try to be smarter than what Apple has figured out over 20 years in user testing, please.

[quote=200308:@Eli Ott]I understand it that way:

[Delete]             [Cancel] *[Do Not Delete]*

Well, you could do that, but that’s kind of confusing to the user if he stops and thinks about what you’re offering there. I.e, what’s the difference between Cancel and Don’t Delete here? There’s none, so you add confusion where clarity is expected. It’s pretty clear if you show this:

             *[Cancel]* [Delete]

or

             *[Don't Delete]* [Delete]

The left blue / thick button suggests the “safe” option while you also do not mess with the expectation that the left button should always be the cancel button.