Dialog - hpi-swa-teaching/MaterialDesignWidgets GitHub Wiki

class MDDialog

You can create a dialog by simply calling MDDialog new openInHand. This will show a dialog without any content.

To create a basic MDDialog you might want to use something like the following:

MDDialog new
    title: 'Basic Dialog';
    text: 'This is just a basic dialog.';
    positiveText: 'OK';
    openInHand.

This will also create two buttons at the bottom of the dialog. By clicking on Cancel the dialog automatically closes itself.

Opening a Dialog

MDDialog has a method for opening itself open and one for closing close.

A typical use case would be opening a custom dialog when a special event happens (e.g. a Click-Event). Therefore you might want to use the following code:

| dialog |
dialog := MDDialog new
    title: 'Reset settings?';
    content: 'This will reset your device to its default factory settings.';
    positiveText: 'Accept';
    negativeText: 'Cancel';
    showNegative: true;
    yourself.

MDContainedButton new 
    text: 'Open Dialog';
    target: [ dialog open ];
    actionSelector: #value;
    openInHand

Customizing a MDDialog

General
  • title: aString set the title of the dialog
  • text: aString set the body text of the dialog
  • content: aStringOrSymbol set the body of the dialog
Dismissing Dialogs
  • autoDismiss: aBoolean close the dialog when clicking positive button default: true
  • dismissOnBackgroundClick: aBoolean close the dialog when clicking on background default: true
Open and Close
  • open open the dialog
  • close close the dialog
Positive Button
  • positiveText: aString set the positive button's text
  • onPositive: aBlock set the block which will be evaluated when positive button is clicked
Negative Button
  • showNegative: aBoolean define whether the negative button should be shown or not default: false
  • negativeText: aString set the negative button's text
  • onNegative: aBlock set the block which will be evaluated when negative button is clicked