警告对话框
模态的询问框,带标题、说明和两个按钮,key 打开期间显示。
ui.alert_dialog基本用法
if ui.button("Delete file…").danger().clicked() { ui.open_dialog("delete");}ui.alert_dialog("delete", "Delete this file?") .description("The file is removed from this device and from everyone it is shared with. This cannot be undone.") .cancel("Cancel") .confirm("Delete") .danger();根据回答执行操作
if ui.button("Reset settings…").outline().clicked() { ui.open_dialog("reset");}// True once, in the frame the confirm button is pressed.if ui.alert_dialog("reset", "Reset all settings?").confirm("Reset").confirmed() { ui.toast("Settings reset");}接口
| 设置 | 说明 |
|---|---|
.description(text: impl Display) | 标题下方的文字。 |
.cancel(text: impl Display) | 取消按钮的文字;默认为 Locale::cancel(“Cancel”)。 |
.confirm(text: impl Display) | 确认按钮的文字;默认为 Locale::ok(“OK”)。 |
.danger() | 标记为不可恢复的操作:使用危险色,初始焦点落在取消按钮上。 |
.confirmed() | 打开时显示对话框,返回本帧是否确认。 |