Skip to main content

Module modal_prompt

Module modal_prompt 

Expand description

Shared content body for a text-entry ModalDialog: PromptBody drops in as the content C while the dialog owns the backdrop, title, footer and Esc, and the body renders an optional caption, an optional field label and a TextInput with selection, clipboard and accessibility. The host reads the result with PromptBody::value.

ⓘ
let body = PromptBody::new("Name", "New volume")
    .with_caption("Choose a name for the volume.");
let dialog = ModalDialog::new("Create volume", body)
    .open(true)
    .with_max_width(420.0)
    .primary_action("Create", move || submit.set(true))
    .secondary_action("Cancel", move || cancel.set(true));
// …on submit: dialog.content().value()

A confirmation that waits for a typed phrase (erasing a disk, deleting a vault) is PromptBody::confirm_phrase with the primary action gated on PromptBody::confirms:

ⓘ
ModalDialog::new("Erase sdb?", PromptBody::confirm_phrase(message, "sdb"))
    .with_destructive(true)
    .primary_action("Erase", erase)
    .primary_enabled_if(PromptBody::confirms)
    .secondary_action("Cancel", cancel);

Structs§

PromptBody
Renders caption → label → field, where caption and label are optional.