Module dcanvas.dialogs.dialog
Common Dialog implementation.
Use to create custom dialogs.
Synopsis
import dcanvas.dialogs.dialog;
// Create custom dialog with custom content and action handling
class MyDialog : Dialog {
this(Window parent) {
super(UIString("My Title"d), parent, DialogFlag.Modal | DialogFlag.Resizable, 400, 300);
// Option 1: Handle dialog results via dialogResult signal
dialogResult = delegate (Dialog dlg, const Action action) {
if (action.id == StandardAction.Ok) {
Log.d("OK clicked");
}
};
}
override void initialize() {
addChild(new TextWidget("msg", UIString("Custom content"d)));
addChild(createButtonsPanel([ACTION_OK, ACTION_CANCEL], 0, 0));
}
}
// Option 2: Override handleAction in your Dialog subclass
class MyDialog2 : Dialog {
this(Window parent) {
super(UIString("Title"d), parent, DialogFlag.Modal, 300, 200);
}
override void initialize() {
addChild(new TextWidget("msg", UIString("Message"d)));
addChild(createButtonsPanel([ACTION_OK, ACTION_CANCEL], 0, 0));
}
override bool handleAction(const Action action) {
if (action.id == StandardAction.Ok) {
Log.d("OK clicked");
close(action);
return true;
}
return super.handleAction(action);
}
}
// Show the dialog
new MyDialog(parentWindow).show();
Classes
| Name | Description |
Dialog
|
base for all dialogs
|
DialogFrame
|
frame with caption for dialog
|