Module dialogs

Module dialogs 

Source
Expand description

Dialog system for AppCUI applications.

This module provides a set of predefined modal windows that are common when using a UI system:

  • Notification dialogs - Show errors, warnings, messages, or ask for validation
  • File dialogs - Allow users to select files to open or save
  • Folder selection dialogs - Allow users to select folders

§Notification Dialogs

The module provides several functions for displaying notifications with different severity levels:

  • error - Shows an error message with an “Ok” button
  • retry - Shows an error message with “Retry” and “Cancel” buttons
  • alert - Shows a warning message with an “Ok” button
  • proceed - Shows a warning message with “Yes” and “No” buttons
  • message - Shows an information message with an “Ok” button
  • validate - Shows a question with “Yes” and “No” buttons
  • validate_or_cancel - Shows a question with “Yes”, “No”, and “Cancel” buttons

§File Dialogs

For file operations, the module offers:

  • open - A dialog for selecting a file to open
  • save - A dialog for selecting a location to save a file

§Folder Selection Dialogs

For folder selection:

§Examples

use appcui::dialogs;

// Show a simple error message
dialogs::error("Error", "An error has occurred");

// Ask the user a yes/no question
if dialogs::validate("Confirm", "Do you want to proceed?") {
    // User clicked "Yes"
} else {
    // User clicked "No" or closed the dialog
}

// Open a file dialog
if let Some(file_path) = dialogs::open("Open File",
                                       "document.txt",
                                       dialogs::Location::Current,
                                       Some("Text files = [txt]"),
                                       dialogs::OpenFileDialogFlags::Icons)
{
    // User selected a file
    println!("Selected file: {:?}", file_path);
}

Structs§

OpenFileDialogFlags
SaveFileDialogFlags
SelectFolderDialogFlags

Enums§

Location
Specifies the initial location for file and folder selection dialogs.
ValidateOrCancelResult
Result of a validation dialog with a cancel option.

Functions§

alert
Displays an alert dialog with an “Ok” button.
error
Displays an error dialog with an “Ok” button.
input
Opens an input dialog for entering a value of type T and returns the value entered by the user or None if the user canceled the operation.
message
Displays a notification dialog with an “Ok” button.
open
Opens a file dialog for opening a file and returns the path of the file selected by the user or None if the user canceled the operation.
proceed
Displays an alert dialog with “Yes” and “No” buttons.
retry
Displays an error dialog with “Retry” and “Cancel” buttons.
save
Opens a file dialog for saving a file and returns the path of the file selected by the user or None if the user canceled the operation.
select_folder
Opens a dialog for selecting a folder and returns the path of the folder selected by the user or None if the user canceled the operation.
validate
Displays a validation dialog with “Yes” and “No” buttons.
validate_or_cancel
Displays a validation dialog with “Yes”, “No”, and “Cancel” buttons.