NAME

Chandra::Dialog - Native dialog boxes for Chandra applications

SYNOPSIS

use Chandra::App;

my $app = Chandra::App->new(title => 'My App');

# File open dialog
my $path = $app->dialog->open_file(title => 'Select a file');
print "Selected: $path\n" if defined $path;

# Directory picker
my $dir = $app->dialog->open_directory;

# Save dialog
my $save = $app->dialog->save_file(
    title   => 'Save As',
    default => 'untitled.txt',
);

# Alert dialogs
$app->dialog->info(title => 'Done', message => 'File saved!');
$app->dialog->warning(message => 'Unsaved changes');
$app->dialog->error(message => 'Could not open file');

DESCRIPTION

Chandra::Dialog provides access to native platform dialog boxes via the underlying webview-c library. All dialogs are modal and block until the user responds.

File open and save dialogs return the selected path, or undef if the user cancelled.

METHODS

new(%args)

Create a new Dialog instance. Usually accessed via $app->dialog.

open_file(%opts)

Show a file-open dialog. Options:

title - Dialog title (default: 'Open File')
filter - File filter string (platform-dependent)

Returns the selected file path, or undef if cancelled.

open_directory(%opts)

Show a directory picker. Options:

title - Dialog title (default: 'Open Directory')

Returns the selected directory path, or undef if cancelled.

save_file(%opts)

Show a file-save dialog. Options:

title - Dialog title (default: 'Save File')
default - Default filename suggestion

Returns the chosen save path, or undef if cancelled.

info(%opts)

Show an informational alert. Options: title, message.

warning(%opts)

Show a warning alert. Options: title, message.

error(%opts)

Show an error alert. Options: title, message.

CONSTANTS

TYPE_OPEN, TYPE_SAVE, TYPE_ALERT
FLAG_FILE, FLAG_DIRECTORY, FLAG_INFO, FLAG_WARNING, FLAG_ERROR

These are exported for advanced usage with the low-level $app->webview->dialog() XS method.

SEE ALSO

Chandra::App