Moose has this nice library for building wizards called Merlin. Unfortunately there’s really no documentation apart from couple of examples. Because I need to use this library (I’m sick of creating forms by hand like some kind of animal…), I might as well publish my notes.
Merlin is available by default in the Moose distribution; for regular Pharo install it via Metacello.
As you can see in the introductory image, the UI consists of three parts:
WizardControl— the main container
WizardPane— a single step of the wizard
WizardPart— a single item in a pane
So you basically create an instance of
WizardControl, add to it a bunch of
WizardPanes, and each pane populate with
To start creating a new wizard, you need an instance of
With that, you are interested mainly in these three methods:
addPane:to add a new pane
opento open the wizard
atEndDo: aOneArgBlockthat will be evaluated when the wizard finished
atEndDo: you can also use
wizardInformations. Both will provide you with a
Dictionary containing the value of each individual
Now you need to populate the wizard with panes.
There are several choices for a
WizardSinglePane— used only if the wizard has a single pane; adds the Finish button
WizardFirstPane— first pane of a multipane wizard; adds the Next button
WizardMiddlePane— middle pane; has the Back and Next buttons
WizardLastPane— last pane; has the Back and Finish buttons
Just make sure you are adding the panes in the correct order (first, middle*, last) XOR (single).
You can also name the pane with
pane name: 'My Pane' (it will appear as the title of the wizard for the active pane).
To add parts to a pane, use one of the following methods
associatedTo: takes a symbol under which you can retrieve the value (output) of the part in
atEndDo: (see WizardControl).
requiring: takes a list of symbols this Part needs to operate
addPart: takes an instance of
row: takes either a part, or a block, e.g.
With a combination of row: and column: you can customize the layout of the wizard to your needs.
Finally you have a wealth of
WizardParts: checkboxes, file inputs, text inputs, etc. Not much point going through them one by one, look at the API to see how each should be used.
Two methods common to all parts that might be interesting:
inGroupboxNamed: aString— a label container around the input
defaultValue: aValueOrBlock— a default value or a one arg block of required inputs