Windows puts a destructive proceed with the committing buttons, before Cancel

Delete and Replace commit, so Windows orders them after the accepting button and before the closing answers and
Cancel; macOS and Linux keep their order. The column footer doc names Alternate's place.
This commit is contained in:
aiongg
2026-11-21 08:39:47 +00:00
parent 2ceaf2410a
commit 074e0cc8f0
2 changed files with 28 additions and 7 deletions
+9 -7
View File
@@ -376,7 +376,8 @@ impl FooterDrop {
pub enum DialogRole {
/// The default outcome: the primary look, last in the row (first on Windows).
Accept,
/// An outcome that destroys something: the danger look.
/// An outcome that destroys something (Delete, Replace): the danger look. It proceeds, so Windows puts it with the
/// accepting button, before Cancel.
Destructive,
/// Leaves without an outcome.
Cancel,
@@ -388,8 +389,9 @@ pub enum DialogRole {
}
impl DialogRole {
/// The position in the row: later roles stand nearer the end. Windows puts the accepting button first and the
/// answers that close the question after it, before Cancel; macOS and Linux put the accepting button last.
/// The position in the row: later roles stand nearer the end. Windows puts the committing buttons first (the
/// accepting one, then a destructive proceed) and the answers that close the question after them, before Cancel;
/// macOS and Linux put the accepting button last.
fn rank(self, windows: bool) -> u8 {
match (windows, self) {
(false, DialogRole::Other | DialogRole::Alternate) => 0,
@@ -397,9 +399,9 @@ impl DialogRole {
(false, DialogRole::Cancel) => 2,
(false, DialogRole::Accept) => 3,
(true, DialogRole::Accept) => 0,
(true, DialogRole::Alternate) => 1,
(true, DialogRole::Cancel) => 2,
(true, DialogRole::Destructive) => 3,
(true, DialogRole::Destructive) => 1,
(true, DialogRole::Alternate) => 2,
(true, DialogRole::Cancel) => 3,
(true, DialogRole::Other) => 4,
}
}
@@ -554,7 +556,7 @@ impl FooterBar {
}
/// The members stand in a column at the top of the bar, each as wide as the widest: the buttons of a dialog whose
/// footer stands beside the body. Buttons go `Accept`, `Cancel`, then the others in the given order.
/// footer stands beside the body. Buttons go `Accept`, `Alternate`, `Cancel`, then the others in the given order.
#[must_use]
pub fn column(mut self) -> Self {
self.props = self.props.layout(BodyLayout::stack());
+19
View File
@@ -415,6 +415,25 @@ fn windows_puts_an_auxiliary_apply_after_cancel() {
assert!(left("OK") < left("Cancel") && left("Cancel") < left("Apply"), "OK, Cancel, Apply from the start edge");
}
/// A destructive proceed is a committing button: Windows puts it first, before Cancel; macOS keeps Cancel nearer the
/// end edge than Delete.
#[trial]
fn a_delete_prompt_reads_delete_then_cancel_on_windows() {
for os in [Os::Windows, Os::Mac] {
let mut fixture = Fixture::new(|ui| {
let mut open = true;
Dialog::new("Delete Layer")
.opened(Bind::bound(&mut open))
.buttons([FooterButton::new("Cancel", DialogRole::Cancel), FooterButton::new("Delete", DialogRole::Destructive)])
.show(ui, |_, _| {});
});
fixture.os(os);
fixture.idle(30);
let left = |name: &str| fixture.by_label(name).expect("the button shows").rect.left();
assert!(left("Delete") < left("Cancel"), "{os:?}: Delete, then Cancel, from the start edge");
}
}
/// Each open of a dialog has its own serial, kept while it stays open, though its id is the same at every open: a
/// reopened dialog is told apart from the one cancelled before it.
#[trial]