|
|
Class: DialogBox
Object
|
+--GraphicsContext
|
+--DeviceGraphicsContext
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--TopView
|
+--StandardSystemView
|
+--ModalBox
|
+--DialogBox
|
+--ActionWaitBox
|
+--Dolphin::ListPrompter
|
+--Dolphin::MessageBox
|
+--Dolphin::Prompter
|
+--EnterBox
|
+--FontPanel
|
+--InfoBox
|
+--LicenceBox
|
+--OptionBox
|
+--Tools::SearchDialog
- Package:
- stx:libwidg
- Category:
- Views-DialogBoxes
- Version:
- rev:
1.298
date: 2010/03/24 12:36:57
- user: cg
- file: DialogBox.st directory: libwidg
- module: stx stc-classLibrary: libwidg
- Author:
- Claus Gittinger
this class implements the common behavior of dialogboxes.
DialogBox is also a superclass of many other boxes - see InfoBox,
WarningBox, YesNoBox etc. for concrete examples.
Most of them simply add buttons or other elements.
For programmatically created boxes, instances support adding of components
in a top-to-bottom fashion, and also keep track of added text-fields and,
since they are most common, automatically create an EnterFieldGroup for
them.
Caveat:
more adding support is required - especially for row-wise construction.
The programmatic interface is best suited for row-wise
arranged components; laying out elements in columns is a bit
complicate - for complicated dialogs, it may be better to not use
the automatic arrangement, but instead give explicit layouts to
the components (in a subclass) or better use the UIPainter.
Compatibility note:
For ST-80 compatibility, DialogBox is also accessable under
the global named 'Dialog' (which is the name of an ST-80 class,
providing a very similar protocol).
This may lead to confusion, if DialogBox is recompiled - you have
to manually assign Dialog again to refer to the new DialogBox class.
In future versions of ST/X, DialogBox may be renamed to Dialog.
Historic note:
originally, ST/X had separate classes for the various entry methods;
there were YesNoBox, EnterBox, InfoBox and so on.
ST-80 has all this defined in the common Dialog.
Therefore, for compatibility, many ST/X methods defined here in Dialogs
class protocol simply dispatch to some other boxes class method.
In the future, those existing subclasses' functionality is going to
be moved full into Dialog, and the subclasses will be replaced by dummy
delegators. (They will be kept for backward compatibility, though).
[instance variables:]
buttonPanel <PanelView> contains the button(s)
okButton <Button> the ok-Button
okAction <Block> the action to be performed when ok is pressed,
or return is pressed.
acceptReturnAsOK <Boolean> if true, pressing the return-key counts
as if ok was pressed. Default is true.
abortButton <Button> the cancel-Button
abortAction <Block> the action to be performed when cancel is
pressed.
yPosisition <Integer> current y position when adding components
leftIndent <Integer> left inset to use when adding components
rightIndent <Integer> right inset to use when adding components
addedComponents <Collection> programmatically added components
inputFieldGroup <EnterFieldGroup>
for added input fields
acceptOnLeave <Boolean> if true (the default) and there are
tabable inputFields, accept and close when
the last field is left. If false, the ok
button must be pressed to close the box.
acceptedValue v(<Boolean>) valueHolder on a boolean
after close: holds true if box was accepted
(i.e. ok-Button was pressed), false if box was
closed via cancel or window manager.
autoAccept Boolean if true, pressing ok (or return)
sends #accept to all subcomponents.
I.e. all subfields update their models
first. The default is true.
variablePanel nil|VPanel an optional additional panel to be filled dynamically
in an aboutToOpenNotification hook.
For compatibility with ST-80, this class is also available under
the global names DialogView and Dialog (see patches file).
Button
CheckToggle
Toggle
EditField
SelectionInListView
FileSelectionList
FramedBox
Separator
[introduction to view programming]
Compatibility-VW
-
choose: aString fromList: list values: listValues lines: maxLines cancel: cancelBlock for: aView
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
This is a new VW2.5 interface - passing an addtional argument.
In ST/X, this is not needed and ignored
-
confirm: aMessageString for: ignoredView
-
VW compatibility - confirm using the same viewStyle as in the view
argument; not supported in ST/X (who mixes styles ?)
-
request: aString for: aView
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or the empty string (if cancel was pressed),
This is a new VW2.5 interface - passing an addtional argument.
In ST/X, this is not needed and ignored
-
request: aString initialAnswer: initial for: aView
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string) or nil (if cancel was pressed).
This is a new VW2.5 interface - passing an addtional argument.
In ST/X, this is not needed and ignored
-
requestFileName: title default: default version: versionSym ifFail: failBlock for: aViewOrNil
-
new VW2.5 interface - passing an addtional argument.
In ST/X, this is not needed and ignored
-
warn: aMessageString for: ignoredView
-
VW compatibility - warn using the same viewStyle as in the view
argument; not supported in ST/X (who mixes styles ?)
class initialization
-
initialize
-
common dialogs
-
about: text label: label icon: image
-
opens an standard about box for an application.
-
aboutClass: aClass
-
opens a standard (simple) aboutBox for aClass.
-
informUser: aString during: aBlock
-
show a message-box while executing aBlock
-
informUser: aString during: aBlock cancel: canCancel
-
show a message-box while executing aBlock
-
information: aString
-
launch a Dialog to tell user something
-
warn: aString
-
launch a Dialog to warn user
confirmation dialogs
-
confirm: aString
-
open a modal yes-no dialog.
Return true for yes, false for no
-
confirm: aString default: what
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
InitialAnswer must be true or false and defines which button is to be
the default (i.e. return-) button
-
confirm: aString initialAnswer: what
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
InitialAnswer must be true or false and defines which button is to be
the default (i.e. return-) button
-
confirm: aString initialAnswer: what noLabel: noText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
InitialAnswer must be true or false and defines which button is to be
the default (i.e. return-) button
-
confirm: aString noLabel: noText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The no-button is labeled noText (for example, if you need a 'cancel' there)
-
confirm: aString title: title
-
open a modal yes-no dialog.
Return true for yes, false for no
-
confirm: aString title: title noLabel: noText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The no buttons label is defined by noText (for example, to make it 'cancel').
-
confirm: aString title: title yesLabel: yesText noLabel: noText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The yes/no buttons labels are defined by yesText/noText.
-
confirm: aString title: title yesLabel: yesText noLabel: noText initialAnswer: what
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The yes/no buttons labels are defined by yesText/noText.
-
confirm: msg withCancel: aBoolean
-
launch a Dialog, which allows user to enter yes, no and optionally: cancel.
return true for 'yes', false for 'no', nil for 'cancel'
-
confirm: msg withCancel: aBoolean default: default
-
launch a Dialog, which allows user to enter yes, no and optionally: cancel.
return true for 'yes', false for 'no', nil for 'cancel'
-
confirm: aString yesLabel: yesText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The yes button's label is defined by yesText.
-
confirm: aString yesLabel: yesText noLabel: noText
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The yes/no buttons' labels are defined by yesText/noText.
-
confirm: aString yesLabel: yesText noLabel: noText initialAnswer: what
-
launch a Dialog, which allows user to enter yes or no.
return true for yes, false for no.
The yes/no buttons labels are defined by yesText/noText.
-
confirmOKCancel: aString
-
launch a Dialog, which allows user to enter OK or Cancel.
return true for OK, false for Cancel.
-
confirmWithCancel: aString
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', nil for 'cancel'
-
confirmWithCancel: aString default: default
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', nil for 'cancel'.
The default argument marks the return-button; it may be one of nil, false or true
-
confirmWithCancel: aString default: defaultValue onCancel: cancelValue
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', cancelValues value for 'cancel'
-
confirmWithCancel: aString default: default title: titleString
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', nil for 'cancel'.
The default argument marks the return-button; it may be one of nil, false or true
-
confirmWithCancel: aString labels: labelArray
-
launch a Dialog, which allows user to enter cancel, no or yes.
Return true for 'yes', false for 'no', nil for 'cancel'.
The default is yes.
The buttons labels are given in labelArray
-
confirmWithCancel: aString labels: buttonLabels default: default
-
launch a Dialog, which allows user to enter yes, no and cancel.
Return true for 'yes', false for 'no', nil for 'cancel'.
The strings for cancel, no and yes are to be passed in
buttonLabels;
The default argument (if non-nil) defines the index of the
return button (1 to 3)
-
confirmWithCancel: aString labels: buttonLabels values: buttonValues default: default
-
launch a Dialog, which allows user to click on any button.
Return the corresponding value from the values array.
The labels for for the buttons are to be passed in
buttonLabels;
The default argument (if non-nil) defines the index of the
return button (1 to n)
-
confirmWithCancel: aString labels: buttonLabels values: buttonValues default: default boxLabel: boxLabelOrNil
-
obsolete - for backward compatibility
-
confirmWithCancel: aString labels: buttonLabels values: buttonValues default: default check: checkLabelOrNil on: checkHolderOrNil title: boxLabelOrNil
-
launch a Dialog, which allows user to click on any button.
Return the corresponding value from the values array.
The labels for for the buttons are to be passed in
buttonLabels;
The default argument (if non-nil) defines the index of the return button (1 to n).
If checkLabel/checkHolder are not nil, and additional labelled checkBox is added to operate on
checkHolder. This can be used for 'do not show this box again' checkItems.
-
confirmWithCancel: aString labels: buttonLabels values: buttonValues default: default title: boxLabelOrNil
-
launch a Dialog, which allows user to click on any button.
Return the corresponding value from the values array.
The labels for for the buttons are to be passed in
buttonLabels;
The default argument (if non-nil) defines the index of the
return button (1 to n)
-
confirmWithCancel: aString onCancel: cancelValue
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', cancelValues value for 'cancel'
-
confirmWithCancel: aString title: titleString
-
launch a Dialog, which allows user to enter yes, no and cancel.
return true for 'yes', false for 'no', nil for 'cancel'
defaults
-
defaultLabel
-
return the boxes default window title.
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
file name dialogs
-
requestDirectoryName
-
same as requestFileName, but only show directories.
-
requestDirectoryName: title
-
same as requestFileName, but only show directories.
-
requestDirectoryName: title default: aFileName
-
same as requestFileName, but only show directories
-
requestDirectoryName: title default: aFileName acceptReturnAsOK: aBoolean
-
same as requestFileName, but only show directories
-
requestDirectoryName: title default: aFileName ifFail: failBlock
-
same as requestFileName, but only show directories
-
requestDirectoryName: title default: aFileName ok: okText abort: abortText
-
same as requestFileName, but only show directories
-
requestDirectoryName: title default: aFileName ok: okText abort: abortText ifFail: failBlock
-
Same as requestFileName, but only show directories.
-
requestDirectoryName: title default: aFileName ok: okText abort: abortText ifFail: failBlock acceptReturnAsOK: aBoolean
-
Same as requestFileName, but only show directories.
Extended to accept return as ok if wanted.
-
requestDirectoryName: titleString default: aFileName ok: okText abort: abortText version: versionSymbol pattern: pattern fromDirectory: aDirectoryPath ifFail: failBlock whenBoxCreatedEvaluate: boxCreatedCallback asLoadDialog: aBoolean
-
same as requestFileName, but only show directories
-
requestFileName
-
launch a Dialog, which allows the user to enter a filename.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestFileName: titleString
-
launch a Dialog, which allows user to enter a filename.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestFileName: titleString default: defaultName
-
launch a Dialog, which allows user to enter a filename.
The box will not allow pressing 'ok' without an entered string.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestFileName: titleString default: defaultName fromDirectory: aDirectoryPath
-
launch a Dialog, which allows user to enter a filename.
The box will not allow pressing 'ok' without an entered string.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestFileName: titleString default: defaultName ifFail: cancelBlockOrValue
-
launch a Dialog, which allows user to enter a filename.
The box will not allow pressing 'ok' without an entered string.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestFileName: titleString default: defaultName ifFail: failReturn pattern: pattern fromDirectory: dir
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from dir.
The box will show ok/cancel in its buttons.
The matchPattern is set to pattern initially.
Return the string or failReturn if cancel was pressed.
-
requestFileName: titleString default: defaultName ok: okText abort: abortText
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName ok: okText abort: abortText pattern: pattern
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName ok: okText abort: abortText pattern: pattern fromDirectory: aDirectoryPathOrNil
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those in aDirectoryPathOrNil, or the
last fileBox directory (default: current directory) (if a nil path is given).
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return the string, or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName ok: okText abort: abortText pattern: pattern fromDirectory: aDirectoryPathOrNil whenBoxCreatedEvaluate: boxCreatedCallback
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those in aDirectoryPathOrNil, or the
last fileBox directory (default: current directory) (if a nil path is given).
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return the string, or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName ok: okText abort: abortText version: versionSymbol ifFail: failBlock pattern: pattern fromDirectory: aDirectoryPath whenBoxCreatedEvaluate: boxCreatedCallback asLoadDialog: aBoolean
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those in aDirectoryPathOrNil, or the
last fileBox directory (default: current directory) (if a nil path is given).
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return the string, or nil if cancel was pressed
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString default: defaultName pattern: pattern
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show ok/cancel in its buttons.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName pattern: pattern fromDirectory: aDirectory
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show ok/cancel in its buttons.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString default: defaultName version: versionSymbol
-
launch a Dialog, which allows user to enter a filename.
The box will not allow pressing 'ok' without an entered string.
Return the pathname string or the empty string if cancel was pressed.
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString default: defaultName version: versionSymbol ifFail: failBlock
-
launch a Dialog, which allows user to enter a filename.
The box will not allow pressing 'ok' without an entered string.
Return the string or the value of failBlock if cancel was pressed.
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString default: defaultName version: versionSymbol ifFail: failBlock fromDirectory: aDirectoryPath
-
launch a Dialog, which allows user to enter a filename.
Return the string or the value of failBlock if cancel was pressed.
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString default: defaultName version: versionSymbol ifFail: failBlock pattern: pattern fromDirectory: aDirectoryPath
-
launch a Dialog, which allows user to enter a filename.
Return the string or the value of failBlock if cancel was pressed.
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString default: defaultName version: versionSymbol ifFail: failBlock pattern: pattern fromDirectory: aDirectoryPath whenBoxCreatedEvaluate: boxCreatedCallback
-
launch a Dialog, which allows user to enter a filename.
Return the string or the value of failBlock if cancel was pressed.
The version argument allows validation of the files existance;
it may be any of:
#mustBeNew - fail (return empty string) if the file exists
#new - confirm if the file exists
#mustBeOld - fail if the file does not exist
#old - confirm if the file does not exist
#any (other) - no validation
-
requestFileName: titleString fromDirectory: aDirectory
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show ok/cancel in its buttons.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString ifFail: cancelBlockOrValue
-
launch a Dialog, which allows user to enter a filename.
Return the pathname string consisting of the full pathname of the filename,
or the value from evaluating cancelBlock (if cancel was pressed).
-
requestFileName: titleString pattern: pattern
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show ok/cancel in its buttons.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileName: titleString pattern: pattern fromDirectory: aDirectory
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those from the current directory.
The box will show ok/cancel in its buttons.
The matchPattern is set to pattern initially.
Return the string or nil if cancel was pressed.
-
requestFileNames: titleString default: defaultName ok: okText abort: abortText ifFail: failBlock pattern: pattern fromDirectory: aDirectoryPath whenBoxCreatedEvaluate: boxCreatedCallback asLoadDialog: asLoadDialog
-
launch a Dialog, which allows user to enter a filename.
The files presented initially are those in aDirectoryPathOrNil, or the
last fileBox directory (default: current directory) (if a nil path is given).
The box will show okText in its okButton, abortText in the abortButton.
The matchPattern is set to pattern initially.
Return all selected Filenames as filenames in a collection, or nil if cancel was pressed
-
requestNewFileName: titleString default: defaultName
-
launch a Dialog, which allows user to enter a filename.
We expect a new files (i.e. nonexisting) name to be enterred,
and confirm if it already exists.
The box will not allow pressing 'ok' without an entered string.
Return the pathname string consisting of the full pathname of the filename,
or an empty string (if cancel was pressed).
-
requestSaveFileName: title default: defaultOrNil fromDirectory: directoryOrNil action: action appendAction: appendActionOrNil
-
save contents into a file - ask user for filename using a fileSelectionBox.
Append is NOT offered, if appendActionOrNil is nil.
fill in the blank dialogs
-
forRequestText: title editViewClass: editViewClass lines: numLines columns: numCols initialAnswer: initialText model: textModel
-
return a dialog asking for multiline text.
The box is not shown yet, for further customization
-
forRequestText: title editViewClass: editViewClass lines: numLines columns: numCols initialAnswer: initialText model: textModel setupWith: aSetupBlockOrNil
-
return a dialog asking for multiline text.
The box is not shown yet, for further customization
-
forRequestText: title lines: numLines columns: numCols initialAnswer: initialText model: textModel
-
return a dialog asking for multiline text.
The box is not shown yet, for further customization
-
request: aString
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or the empty string (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial
-
launch a Dialog, which allows user to enter a string.
If aPoint is nonNil, the box is shown there, optionally centered around
that point.
If it is nil, it is shown at the current pointer position or at the
screen center.
Return the string or an empty string (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial okLabel: okLabel cancelLabel: cancelLabel onCancel: cancelValue
-
launch a Dialog, which allows user to enter a string.
If aPoint is nonNil, the box is shown there, optionally centered around it.
If it is nil, it is shown at the current pointer position or at the
screen center (if centered is true).
The ok-button is labelled okLabel (or the default, ifNil),
the cancel-button is labelled cancelLabel (or the default, ifNil).
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial okLabel: okLabel cancelLabel: cancelLabel title: titleString onCancel: cancelValue
-
launch a Dialog, which allows user to enter a string.
The dialogs window is titled titleString, or the default (if nil).
If aPoint is nonNil, the box is shown there, optionally centered around it.
If it is nil, it is shown at the current pointer position or at the
screen center (if centered is true).
The ok-button is labelled okLabel (or the default, ifNil),
the cancel-button is labelled cancelLabel (or the default, ifNil).
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial okLabel: okLabel cancelLabel: cancelLabel title: titleString onCancel: cancelValue list: listToSelectFrom
-
launch a Dialog, which allows user to enter a string.
The dialogs window is titled titleString, or the default (if nil).
If aPoint is nonNil, the box is shown there, optionally centered around it.
If it is nil, it is shown at the current pointer position or at the
screen center (if centered is true).
The ok-button is labelled okLabel (or the default, ifNil),
the cancel-button is labelled cancelLabel (or the default, ifNil).
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial okLabel: okLabel cancelLabel: cancelLabel title: titleString onCancel: cancelValue list: listToSelectFrom initialSelection: anInterval
-
launch a Dialog, which allows user to enter a string.
The dialogs window is titled titleString, or the default (if nil).
If aPoint is nonNil, the box is shown there, optionally centered around it.
If it is nil, it is shown at the current pointer position or at the
screen center (if centered is true).
The ok-button is labelled okLabel (or the default, ifNil),
the cancel-button is labelled cancelLabel (or the default, ifNil).
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centeredOrNil action: resultAction initialAnswer: initial okLabel: okLabel cancelLabel: cancelLabel title: titleString onCancel: cancelValue list: listToSelectFrom initialSelection: anInterval entryCompletionBlock: entryCompletionBlock
-
launch a Dialog, which allows user to enter a string.
The dialogs window is titled titleString, or the default (if nil).
If aPoint is nonNil, the box is shown there, optionally centered around it.
If it is nil, it is shown at the current pointer position or at the
screen center (if centered is true).
The ok-button is labelled okLabel (or the default, ifNil),
the cancel-button is labelled cancelLabel (or the default, ifNil).
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint centered: centered action: resultAction initialAnswer: initial onCancel: cancelValue
-
launch a Dialog, which allows user to enter a string.
If aPoint is nonNil, the box is shown there, optionally centered.
If it is nil, it is shown at the current pointer position or at the screen center.
Return the string or the value of cancelValue (if cancel was pressed)
-
request: aString displayAt: aPoint initialAnswer: initial
-
launch a Dialog, which allows user to enter something.
The boxes topLeft is placed at aPoint, or under the mouse pointer (if aPoint is nil).
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
request: aString initialAnswer: initial
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
request: aString initialAnswer: initial entryCompletionBlock: entryCompletionBlock
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
request: aString initialAnswer: initial initialSelection: anInterval
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
request: aString initialAnswer: initial list: aList
-
launch a Dialog, which allows user to enter something,
or select from a list of values.
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
request: aString initialAnswer: initial okLabel: okLabel title: titleString
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString initialAnswer: initial okLabel: okLabel title: titleString list: list
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString initialAnswer: initial okLabel: okLabel title: titleString onCancel: cancelAction
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString initialAnswer: initial okLabel: okLabel title: titleString onCancel: cancelAction list: listOfChoices
-
launch a Dialog, which allows user to enter something
(with a list of choices for fast input).
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString initialAnswer: initial okLabel: okLabel title: titleString onCancel: cancelAction list: listOfChoices entryCompletionBlock: entryCompletionBlock
-
launch a Dialog, which allows user to enter something
(with a list of choices for fast input).
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString initialAnswer: initial onCancel: cancelAction
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or cancelValue (if cancel was pressed)
-
request: aString list: listOfChoices
-
launch a Dialog, which allows user to enter something,
but adds a list of choices for fast input.
Return the entered string (may be empty string)
or the empty string (if cancel was pressed)
-
request: aString okLabel: okLabel
-
launch a Dialog, which allows user to enter something.
The okButton is labelled as okLabel.
Return the entered string (may be empty string)
or the empty string (if cancel was pressed)
-
request: aString okLabel: okLabel onCancel: cancelValue
-
launch a Dialog, which allows user to enter something.
The okButton is labelled as okLabel.
Return the entered string (may be empty string)
or the value from evaluating cancelValue (if cancel was pressed)
-
request: aString okLabel: okLabel title: titleString onCancel: cancelValue
-
launch a Dialog, which allows user to enter something.
The okButton is labelled as okLabel.
Return the entered string (may be empty string)
or the value from evaluating cancelValue (if cancel was pressed)
-
request: aString onCancel: cancelActionOrValue
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string)
or the value of cancelAction (if cancel was pressed).
-
request: aString title: titleString initialAnswer: initial
-
launch a Dialog, which allows user to enter something.
Return the entered string (may be empty string) or nil (if cancel was pressed)
-
requestNumber: aString
-
launch a Dialog, which allows user to enter a number.
Return the numeric value or nil
(for an invalid number or if cancel was pressed)
-
requestNumber: aString initialAnswer: aNumber
-
launch a Dialog, which allows user to enter a number.
Return the numeric value or nil
(for an invalid number or if cancel was pressed)
-
requestPassword: aString
-
launch a Dialog, which allows user to enter something invisibly.
Return the entered string (may be empty string)
or nil (if cancel was pressed)
-
requestText: title
-
open a dialog asking for multiline text.
Return a stringCollection or nil if cancelled.
-
requestText: title initialAnswer: initialAnswer
-
open a dialog asking for multiline text.
Return a stringCollection or nil if cancelled.
-
requestText: title lines: numLines columns: numCols initialAnswer: initialText
-
open a dialog asking for multiline text.
Return a stringCollection or nil if cancelled.
multiple choice dialogs
-
choose: aString fromList: list lines: maxLines
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list lines: maxLines initialSelection: initialSelection
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list lines: maxLines initialSelection: initialSelection title: windowTitle
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list lines: maxLines title: windowTitle
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock multiple: multiple
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
If a list is present, multiple controls if multiple selections are allowed.
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock multiple: multiple postBuildBlock: aBlockOrNil
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
If a list is present, multiple controls if multiple selections are allowed.
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock postBuildBlock: postBuildBlock
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues initialSelection: initialListSelectionOrNil buttons: buttonLabels values: buttonValues default: defaultValue lines: maxLines cancel: cancelBlock multiple: multiple postBuildBlock: aBlockOrNil
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
If a list is present, multiple controls if multiple selections are allowed.
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues initialSelection: initialListSelectionOrNil buttons: buttonLabels values: buttonValues default: defaultValue lines: maxLines cancel: cancelBlock multiple: multiple title: windowTitle postBuildBlock: aBlockOrNil
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
If a list is present, multiple controls if multiple selections are allowed.
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues initialSelection: initialListSelectionOrNil buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock multiple: multiple postBuildBlock: aBlockOrNil
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
If a list is present, multiple controls if multiple selections are allowed.
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: listValues lines: maxLines cancel: cancelBlock
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: values lines: maxLines cancel: cancelBlock title: windowTitle
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: values lines: maxLines initialSelection: initialSelection title: windowTitle
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString fromList: list values: values lines: maxLines title: windowTitle
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
choose: aString label: windowLabel image: imageOrNil labels: buttonLabels values: values default: default onCancel: cancelValue
-
launch a Dialog, which allows user to enter any of buttonLabels.
Returning a corresponding value from the values-array.
The default entries button is marked as a return button and entering
return will choose that value; hitting escape returns cancelValue.
For a good userInterface style, we recommend this being the last
entry (to make the right-most button the default button).
-
choose: aString label: windowLabel labels: buttonLabels values: values default: default
-
launch a Dialog, which allows user to enter any of buttonLabels.
Returning a corresponding value from the values-array.
The default entries button is marked as a return button and entering
return will choose that value; hitting escape returns nil.
For a good userInterface style, we recommend this being the last
entry (to make the right-most button the default button).
-
choose: aString label: windowLabel labels: buttonLabels values: values default: default onCancel: cancelValue
-
launch a Dialog, which allows user to enter any of buttonLabels.
Returning a corresponding value from the values-array.
The default entries button is marked as a return button and entering
return will choose that value; hitting escape returns cancelValue.
For a good userInterface style, we recommend this being the last
entry (to make the right-most button the default button).
-
choose: aString labels: buttonLabels values: values default: default
-
launch a Dialog, which allows user to enter any of buttonLabels.
Returning a corresponding value from the values-array.
The default entries button is marked as a return button and entering
return will choose that value.
For a good userInterface style, we recommend this being the last
entry (to make the right-most button the default button).
-
chooseMultiple: aString fromList: list values: listValues buttons: buttonLabels values: buttonValues lines: maxLines cancel: cancelBlock
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
-
chooseMultiple: aString fromList: list values: listValues initialSelection: initialListSelectionOrNil lines: maxLines
-
launch a Dialog showing the message and list.
The user can select an item and click ok; in this case, the corresponding value
from listValues is returned (doubleclick works as well).
The list may be suppressed (if the list arg is nil).
Below the list, an optional row of buttons is shown, which can also be
clicked upon, and a corresponding value from buttonValues is returned.
If cancel is pressed, the value of cancelBlock is returned.
Pressing ok without a selection is treated like cancel.
private
-
showAndThenDestroyBox: aBox
-
-
showBox: aBox
-
queries
-
defaultOKButtonAtLeft
-
somewhat of a kludge:
some viewStyles have ok at left (motif), others at right...
-
defaultParentWindow
-
return a default parent (top-) window for the dialog.
Here, the currently active view is returned, if there
is one; otherwise, the first encountered topView is
returned.
smalltalk dialogs
-
requestClass: aString
-
launch a Dialog, which allows user to enter an existing classes name.
Return the entered class or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestClass: aString initialAnswer: initialAnswer
-
launch a Dialog, which allows user to enter an existing classes name.
Return the entered class or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestClass: aString list: list okLabel: okLabel initialAnswer: initial
-
launch a Dialog, which allows user to enter an existing classes name.
Return the entered class or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestClass: aString okLabel: okLabel initialAnswer: initial
-
launch a Dialog, which allows user to enter an existing classes name.
Return the entered class or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestClassName: aString list: list okLabel: okLabel initialAnswer: initial
-
launch a Dialog, which allows user to enter a class name.
Return the entered string (may be empty string) or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestClassName: aString okLabel: okLabel initialAnswer: initial
-
launch a Dialog, which allows user to enter a class name.
Return the entered string (may be empty string) or nil (if cancel was pressed).
The entryField does classNameCompletion on TAB.
-
requestName: title fromList: nameList title: boxTitle initialAnswer: initialTextOrNil
-
Ask for a name from a list (used for namespaces and sharedPools)
-
requestNameSpace: title initialAnswer: initialTextOrNil
-
Ask for a namespaces name
-
requestNameSpace: title title: boxTitle initialAnswer: initialTextOrNil
-
Ask for a namespaces name
-
requestProject: title from: listOfProjects initialAnswer: initialTextOrNil suggestions: suggestions
-
Ask for a project (package-id)
-
requestProject: title initialAnswer: initialTextOrNil suggestions: suggestions
-
Ask for a project (package-id)
-
requestSelector: aString initialAnswer: initial
-
launch a Dialog, which allows user to enter a method selector.
Return the entered string (may be empty string) or nil (if cancel was pressed).
The entryField does selectorCompletion on TAB.
-
requestSelector: aString okLabel: okLabel initialAnswer: initial
-
launch a Dialog, which allows user to enter a method selector.
Return the entered string (may be empty string) or nil (if cancel was pressed).
The entryField does selectorCompletion on TAB.
-
requestSharedPool: title title: boxTitle initialAnswer: initialTextOrNil
-
Ask for a sharedPools name
accessing-behavior
-
abortAction: aBlock
-
define the action to be performed when abort is pressed
-
acceptCheck: aBlock
-
if nonNil, the acceptCheck-block is evaluated when the dialog is
accepted (ok-button or Return-key). If it returns true, the box is closed,
otherwise not. Of course, you may also use a valueHolder instead of a block
to provide the check value.
-
acceptOnLeave: aBoolean
-
define the behavior when the last input field is left via cursor keys.
The default is to accept & close the dialog (i.e. true).
-
acceptReturnAsOK: aBoolean
-
turn on/off interpretation of return-key as ok.
Default is on
-
action: aBlock
-
set the action to be performed when user presses ok-button;
aBlock must be nil or a block. This method simply
reuses okAction: and has been added for a consistent action-setting
protocol.
-
focusOnField: anInputField
-
arrange for the argument to get the focus (initially)
-
focusToOKOnLeave: aBoolean
-
define the behavior when the last input field is left via a return
or cursor key.
The default is to shift the focus to the OK button (i.e. true).
If turned off, the OK is immediately performed, i.e.
the dialog is accepted & closed.
-
hideOnAccept: aBoolean
-
control if the dialog should close when accepted.
The default is true
-
makeTabable: aComponentOrSubcomponent
-
add a component (usually a subcomponent, of which the dialog
does not know) to the list of tabable ones (i.e. those, that can be
stepped through via FocusNext/FocusPrevious).
Toplevel tabable components are usually added with #addComponent:tabable:
-
makeTabable: aComponentOrSubcomponent after: anotherComponent
-
add a component (usually a subcomponent, of which the dialog
does not know) to the list of tabable ones (i.e. those, that can be
stepped through via FocusNext/FocusPrevious).
Toplevel tabable components are usually added with #addComponent:tabable:
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
makeUntabable: aComponentOrSubcomponent
-
-
noAction: aBlock
-
define the action to be performed when 'no' is pressed
-
okAction: aBlock
-
define the action to be performed when ok is pressed
-
title: aString yesAction: yesBlock noAction: noBlock
-
define title and actions
-
yesAction: aBlock
-
define the action to be performed when 'yes' is pressed
-
yesAction: yesBlock noAction: noBlock
-
define both actions
accessing-components
-
abortButton
-
return the abortButton - this access is provided to allow
setting the buttons look (for example: colors or font)
-
buttonPanel
-
return the buttonPanel - this access is provided to allow
setting the buttons look (for example: colors or font)
-
cancelButton
-
same as #abortButton;
return the abortButton - this access is provided to allow
setting the buttons look (for example: colors or font)
-
noButton
-
return the no-button
-
okButton
-
return the okButton - this access is provided to allow
setting the buttons look (for example: colors or font)
-
verticalPanel
-
if there is none yet, create and add a vertical panel.
This can be used to additional components in an aboutToOpen hook callback.
-
yesButton
-
return the 'yes'-button
accessing-elements
-
componentAt: name
-
retrieve a component by name - to access it, it must have been
named previously with #name:as:
-
name: element as: name
-
assign a name to a component. This can be done during construction,
to allow later access to the components (i.e. without a need to
remember them in some instVars)
accessing-look
-
abortText: aString
-
define the label in the abort-button
-
hideButtons
-
hides the buttonPanel (i.e. the ok and cancel buttons if any)
-
noLabel: aString
-
define the label of the 'no'-button.
And alias for #noText: - for backward compatibility
-
noText: aString
-
define the label of the no-button.
If not set, it defaults to the resource-string for 'no'.
-
okText: aString
-
define the text in the ok-button
-
okText: okString abortText: abortString
-
set both texts displayed in the buttons
-
okText: yesString noText: noString
-
define the labels of both buttons.
Alias for yesText:noText: for backward compatibility.
-
title: aString yesText: yesString noText: noString
-
define title and button labels
-
yesLabel: aString
-
define the label of the 'yes'-button.
An alias for #yesText: for backward compatibility.
-
yesText: aString
-
define the label of the 'yes'-button
-
yesText: yesString noText: noString
-
define the labels of both buttons
accessing-models
-
accept
-
return the valueHolder holding true when the box
is accepted, false if closed via the windowManager or
the cancel button.
This is confusing: this method was originally called #acceptValue,
but renamed for compatibility with ST-80.
This looks like a bad name to me, since in most other situations, #accept
is used to force an accept, not to return some valueHolder ...).
-
acceptChannel
-
same as #accept: return the valueHolder which is set to true when the box
is accepted
-
acceptChannel: aValueHolder
-
set the valueHolder which is set to true when the box
is accepted
-
aspectAt: anAspectSymbol put: aDataModel
-
return the dataModel for some aspect, nil if no such dataModel was defined;
requires that a corresponding dataModel has been set (usually during
initialization) via the #aspectAt:put: message.
Allows users of boxes to access individual values - especially useful,
in multi-field dialogs.
-
aspectFor: anAspectSymbol
-
return the dataModel for some aspect, nil if no such dataModel was defined;
requires that a corresponding dataModel has been set (usually during
initialization) via the #aspectAt:put: message.
Allows users of boxes to access individual values - especially useful,
in multi-field dialogs.
-
cancel
-
construction-adding
-
addComponent: aComponent
-
add any component with its preferred height and full width.
Returns the component.
-
addComponent: aComponent indent: indent
-
add any component with its preferred height and full width.
The indent is temporarily changed to indent.
Returns the component.
-
addComponent: aComponent indent: indent tabable: tabable
-
add any component with its preferred height and full width.
The indent is temporarily changed to indent.
Returns the component.
-
addComponent: aComponent indent: indent withExtent: ext
-
add any component with some given extent.
Returns the component.
-
addComponent: aComponent indent: indent withHeight: height
-
add any component with some given height and full width.
Returns the component.
-
addComponent: aComponent tabable: tabable
-
add any component with its preferred height and full width.
Returns the component.
-
addComponent: aComponent tabable: tabable tabbedComponent: subComponent
-
add any component with its preferred height and full width.
Returns the component.
-
addComponent: aComponent withExtent: ext
-
add any component with some given extent.
Returns the component.
-
addComponent: aComponent withHeight: height
-
add any component with some given height and full width.
Returns the component.
-
addLabelledField: aView label: labelString adjust: labelAdjust tabable: tabable from: leftX to: rightX separateAtX: relativeX
-
add a label and some view side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
-
addLabelledField: aView label: labelString adjust: labelAdjust tabable: tabable from: leftX to: rightX separateAtX: relativeX nameAs: aName
-
add a label and some view side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
-
addLabelledField: aView label: labelString adjust: labelAdjust tabable: tabable from: leftX to: rightX separateAtX: relativeX nameAs: aName foregroundColor: fgColor
-
add a label and some view side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
-
addLabelledField: aView label: labelString adjust: labelAdjust tabable: tabable separateAtX: relativeX
-
add a label and some view side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
-
addMessage: labelString centered: centered
-
-
addMessage: labelString textLine: valueHolder boundary: fraction
-
-
addMessage: labelString textLine: valueHolder type: typeSymbolOrNil boundary: fraction
-
-
addTextLabel: aString
-
create a text label - the name has been choosen for ST-80 compatibility;
however, ST/X labels allow image labels too.
Returns the label.
-
addTextLabelOn: aValueHolder
-
create a text label showing the contents of a valueHolder.
Returns the label.
-
addToInputFieldGroup: aComponentOrSubcomponent
-
add a component to the input group.
The argument, aComponentOrSubcomponent may even be a nested subcomponent of
a topLevel component.
-
addToInputFieldGroup: aComponentOrSubcomponent before: anotherComponent
-
add a component to the input group.
The argument, aComponentOrSubcomponent may even be a nested subcomponent of
a topLevel component.
-
removeFromInputFieldGroup: aComponentOrSubcomponent
-
remove a component from the input group.
The argument, aComponentOrSubcomponent may even be a nested subcomponent of
a topLevel component.
construction-buttons
-
addAbortAndOkButtons
-
create both abort- and Ok Buttons
-
addAbortButton
-
create an abortButton - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
Returns the button.
-
addAbortButton: aButton
-
add an already created abortButton - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
Returns the button.
-
addAbortButtonLabelled: buttonLabel
-
create an abortButton with a label - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
A nil argument creates one with the default label.
Returns the button.
-
addButton: aButton
-
add a button into the buttonPanel.
Returns the button.
-
addButton: aButton after: someOtherButtonOrNil
-
add a button into the buttonPanel.
If the argument someOtherButtonOrNil is nil, the button is
added at the end.
-
addButton: aButton before: someOtherButtonOrNil
-
add a button into the buttonPanel.
If the argument someOtherButtonOrNil is nil, the button is
added upFront.
-
addHelpButtonFor: pathToHelpText
-
add a help button to the buttonPanel.
The argument, pathToHelpText should specify the path to the help
text under either the doc/online/<language> or the help/<language>
directory.
-
addOK: checkBlock
-
-
addOkButton
-
create an okButton - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
Returns the button.
-
addOkButton: aButton
-
add an already created okButton - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
Returns the button.
-
addOkButtonLabelled: buttonLabel
-
create an okButton with a label - to be sent from redefined initialize
methods in subclasses or when creating a box programmatically.
A nil argument creates one with the default text.
Returns the button.
construction-check & comboboxes
-
addCheckBox: label on: aModel
-
create a checkBox with label on aModel and add it.
Returns the box.
-
addCheckBox: label on: aModel tabable: tabable
-
create a checkBox with label on aModel and add it.
Returns the box.
-
addComboBoxOn: aModel
-
create a comboBoxView on aModel and add it.
Returns the comboBoxView.
-
addComboBoxOn: aModel tabable: tabable
-
create a comboBoxView on aModel and add it.
Returns the comboBoxView.
-
addComboListOn: aModel
-
create a comboListView on aModel and add it.
Returns the comboListView.
-
addComboListOn: aModel tabable: tabable
-
create a comboListView on aModel and add it.
Returns the comboListView.
construction-inputfields
-
addFilenameInputFieldOn: aModel in: aDirectory tabable: tabable
-
create a fileName input field on aModel and add it.
Returns the field. This is much like a normal input field,
but supports filename completion.
-
addInputField: aField
-
add an already created input field.
Returns the field.
-
addInputField: aField tabable: tabable
-
add an already created input field.
If tabable is true, the field is put into a group, to allow
stepping through the fields with #Cursor/#Return keys.
Returns the field.
-
addInputFieldOn: aModel
-
create an input field on aModel and add it.
Returns the field.
-
addInputFieldOn: aModel tabable: tabable
-
create an input field on aModel and add it.
If tabable is false, the field cannot be tabbed into
and return does not close the box.
(pointer must be moved into it).
Returns the field.
-
addLabelledInputField: labelString adjust: labelAdjust on: model tabable: tabable from: leftX to: rightX separateAtX: relativeX
-
add a label and an inputField side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
-
addLabelledInputField: labelString adjust: labelAdjust on: model tabable: tabable separateAtX: relativeX
-
add a label and an inputField side-by-side.
The labels goes from 0.0 to relativeX; the inputField from relativeX to 1.0.
The labels string is defined by labelString and adjusted according to labelAdjust.
The inputField gets model as its model.
Return the inputField.
construction-layout
-
addGap
-
VW compatibility
-
addGap: pixels
-
VW compatibility
-
addHorizontalLine
-
add a horizontal line as separator
-
addVerticalSpace
-
add a default vertical space (1 mm)
-
addVerticalSpace: nPixel
-
add some pixels of space to the next component
-
bottomAlign: widgets
-
mhmh - seems similar to out stickAtBottom functionality - to be checked
-
bottomAlignLowerEdge: widget
-
mhmh - seems similar to out stickAtBottom functionality - to be checked
-
leftIndent
-
return the current indent
(current x position - thats where the next component will be located).
-
leftIndent: aNumber
-
set the left indent
(current x position - that's where the next component(s) will be located).
Setting this before adding a component will place it indented
-
rightIndent
-
return the current right indent.
-
rightIndent: aNumber
-
set the right indent
-
setInitialGap
-
Created: / 4.2.2000 / 00:01:44 / cg
-
stickAtBottomWithFixHeight: aComponent
-
arrange for a component to be positioned at a constant offset
from the bottom of the box and its height to remain the same.
This will keep the component at a constant distance from the bottom
(without this setup, it would stay at a constant offset from the top).
ATTENTION: use this as a last step, after all components have been added.
-
stickAtBottomWithFixHeight: aComponent left: left right: right
-
arrange for a component to be positioned at a constant offset
from the bottom of the box and its height to remain the same.
This will keep the component at a constant distance from the bottom
(without this setup, it would stay at a constant offset from the top).
ATTENTION: use this as a last step, after all components have been added.
-
stickAtBottomWithVariableHeight: aComponent
-
arrange for a component to be positioned at a constant offset
from the bottom of the box and its height to be adjusted.
This will resize the component for a constant distance from the top,
and the bottom.
(without this setup, its height would remain constant).
ATTENTION: use this as a last step, after all components have been added.
-
yPosition
-
return the current y position (thats where the next component
will be located).
-
yPosition: aNumber
-
set the current y position (thats where the next component
will be located).
construction-lists
-
addList: listHolder lines: nLines validation: validateionBlock
-
-
addListBoxOn: aModel
-
add a selectionInListView to the box.
The listViews ScrollWrapper is returned
-
addListBoxOn: aModel class: aListViewClass
-
create & add an instance of aListViewClass to the box.
The listViews ScrollWrapper is returned
-
addListBoxOn: aModel class: aListViewClass withNumberOfLines: numLines
-
create and add an instance of aListViewClass to the box.
The list has numLines (if nonNil) number of lines shown.
The listViews ScrollWrapper is returned
-
addListBoxOn: aModel class: aListViewClass withNumberOfLines: numLines hScrollable: hs vScrollable: vs
-
add an instance of aListViewClass (selectionInListView) to the box.
The list has numLines (if nonNil) number of lines shown.
If scrolled, the ScrollWrapper is returned - otherwise the listView.
-
addListBoxOn: aModel withNumberOfLines: numLines
-
add a selectionInListView to the box.
The list has numLines (if nonNil) number of lines shown.
The listViews ScrollWrapper is returned
-
addListBoxOn: aModel withNumberOfLines: numLines hScrollable: hs vScrollable: vs
-
add a selectionInListView to the box.
The list has numLines (if nonNil) number of lines shown.
If scrolled, the ScrollWrapper is returned - otherwise the listView.
-
addPopUpList: labelString on: aModel
-
create a popUpList with a label on aModel and add it.
Returns the box.
-
addPopUpList: labelString on: aModel tabable: tabable
-
create a popUpList on aModel and add it.
Returns the popUpList.
-
addPopUpListOn: aModel
-
create a popUpList on aModel and add it.
Returns the box.
-
addPopUpListOn: aModel tabable: tabable
-
create a popUpList on aModel and add it.
Returns the popUpList.
-
addTextBoxOn: aModel class: aListViewClass withNumberOfLines: numLines hScrollable: hs vScrollable: vs
-
add an instance of aListViewClass to the box.
The list has numLines (if nonNil) number of lines shown.
If scrolled, the ScrollWrapper is returned - otherwise the listView.
construction-rows & columns
-
addColumn: aRow fromX: leftX toX: rightX collect: aBlock
-
add some elements in a vertical column.
Equally space elements as returned from aBlock.
-
addColumn: aRow fromX: leftX toX: rightX collect: aBlock tabable: tabable
-
add some elements in a vertical column.
Equally space elements as returned from aBlock.
-
addColumn: aRow fromX: leftX toX: rightX collect: aBlock tabable: tabable horizontalLayout: hLayout
-
add some elements in a vertical column.
Equally space elements as returned from aBlock.
-
addRow: aCol fromX: leftX toX: rightX collect: aBlock
-
add some elements in a horizontal row.
Equally space elements as returned from aBlock.
Advance y.
-
addRow: aCol fromX: leftX toX: rightX collect: aBlock tabable: tabable
-
add some elements in a horizontal row.
Equally space elements as returned from aBlock.
Advance y.
-
addRow: aCol fromX: leftX toX: rightX collect: aBlock tabable: tabable horizontalLayout: hLayout
-
add some elements in a horizontal row.
Equally space elements as returned from aBlock.
Advance y.
-
addRow: aCol fromX: leftX toX: rightX collect: aBlock tabable: tabable horizontalLayout: hLayout verticalLayout: vLayout
-
add some elements in a horizontal row.
Equally space elements as returned from aBlock.
Advance y.
explicit focus control
-
focusOnOk
-
initialization
-
initialize
-
-
reAdjustGeometry
-
sent late in snapin processing - gives me a chance
to resize for changed font dimensions.
private
-
basicAddComponent: aComponent
-
add a component, dont change its size
-
hideAndEvaluate: aBlock
-
if I am modal, make myself invisible and evaluate aBlock.
If nonModal, stay up, but also evaluate the block.
-
preOpen
-
Created: / 4.2.2000 / 00:10:48 / cg
-
realize
-
if any inputFields where added, activate the first one
-
resize
-
queries
-
accepted
-
after the box has closed:
return true if accepted, false if canceled
-
interfaceSpecFor: aSelector
-
return an interface spec.
Notice - Dialog should be moved under AppModel so this becomes obsolete.
-
maxPreferredWidthOfAddedComponents
-
helper for computing my preferred extent.
That is the max component width
-
positionOffset
-
return the delta, by which the box should be displayed
from the mouse pointer. Here, an offset is returned, which
makes the center of the first return-Button in the panel
appear under the cursor. If there is no such button,
use my superclasses offset.
-
preferredExtent
-
return my preferred extent.
That is the max component width, or my current width (default);
whichever is larger, by the sum of the component's heights.
-
specificationFor: aKey
-
return an interface specs literal encoding.
Notice - Dialog should be moved under AppModel so this becomes obsolete.
user actions
-
abortPressed
-
sent by the cancel button; user pressed abort button
- hide myself and evaluate okAction
-
actionArgument
-
-
closeCancel
-
closed via escape
-
doAccept
-
let all components accept (i.e. update their model from the values),
then set my accept value to true.
This is confusing: this method was originally called #accept,
but renamed for compatibility with ST-80, where #accept returns the
accept-valueHolder (which looks like a bad name to me ...).
-
keyPress: aKey x: x y: y
-
return-key duplicates ok-function if acceptReturnAsOK is true
-
lastFieldLeft
-
if the dialog involves input fields, this is called
when the last field is left by Return-key or NextField-key
-
okPressed
-
sent by the okButton; user pressed ok-button
- make myself invisible and if an action was specified do it
-
openDialog
-
historically, DialogBox was used as an abstract class as a base for InfoBox,
YesNoBox etc.
However, the programmatic construction protocol (#addComponent:)
now allows those classes to be easily replaced and future versions of
ST/X may do this and make those subclasses obsolete.
However, dummy stubs will remain to exist for backward compatibility
(i.e. do not fear using YesNoBox, EnterBox etc.)
For most simple standard dialogs, there are ready to use
methods in the class protocol.
For example:
info & warnings:
Dialog information:'hi there'
|
yes/no questions:
(Dialog confirm:'is this simple ?')
ifTrue:[
Transcript showCR:'thats what I expected'
] ifFalse:[
Transcript showCR:'read more examples and documentation'
]
|
yes/no question with cancel option:
|answer|
answer := Dialog confirmWithCancel:'is this simple ?'.
answer isNil ifTrue:[
Transcript showCR:'no easy decision'
] ifFalse:[
answer ifTrue:[
Transcript showCR:'thats what I expected'
] ifFalse:[
Transcript showCR:'read more examples and documentation'
]
]
|
asking for a string:
|s|
s := Dialog request:'enter your name, please:'.
s notEmpty ifTrue:[
Transcript showCR:'you entered: ' , s.
]
|
asking for a string with given default:
|s|
s := Dialog
request:'enter your name, please:'
initialAnswer:(OperatingSystem getLoginName).
s notEmpty ifTrue:[
Transcript showCR:'you entered: ' , s.
]
|
asking for a filename:
|s|
s := Dialog
requestFileName:'select a file, please:'
default:''.
Transcript show:'you entered: '; showCR:s.
|
with a namefiler pattern:
|s|
s := Dialog
requestFileName:'select a file, please:'
default:''
pattern:'*.rc'.
Transcript show:'you entered: '; showCR:s.
|
another namefiler pattern:
|s|
s := Dialog
requestFileName:'select a file, please:'
default:''
pattern:'*.rc;*.st;*.h'.
Transcript show:'you entered: '; showCR:s.
|
with changed button label and pattern:
|s|
s := Dialog
requestFileName:'select a file, please:'
default:''
ok:'show'
abort:'cancel'
pattern:'*.rc'.
Transcript show:'you entered: '; showCR:s.
|
asking for a password:
|s|
s := Dialog
requestPassword:'enter your secret, please:'.
Transcript show:'you entered: '; showCR:s.
|
multiple choice dialogs:
Dialog
choose:'choose any'
fromList:nil
values:nil
buttons:#('one' 'two' 'three' 'four')
values:#(1 2 3 4)
lines:nil
cancel:nil
|
multiple choice dialog, with list & buttons:
Transcript showCR:(
Dialog
choose:'choose example'
fromList:#('one' 'two' 'three' 'four')
values:#(1 2 3 4)
buttons:#('five' 'six' 'seven')
values:#(5 6 7)
lines:4
cancel:[Transcript flash. #aborted]
)
|
You can (and often have to) construct custom dialogs programmatically,
from individual components. As shown in the following examples:
basic (unusable) example:
still unusable - only an ok-button:
DialogBox new addOkButton; open
|
both ok- and abortButtons:
DialogBox new addAbortButton; addOkButton; open
|
with different ok-label:
DialogBox new addAbortButton; addOkButtonLabelled:'yeah'; open
|
adding a (centered by default) textlabel gives an infoBox:
DialogBox new
addTextLabel:'hello';
addOkButton;
open
|
a textlabel with abort- and okButton gives a yesNoBox:
DialogBox new
addTextLabel:'hello';
addAbortButton;
addOkButton;
open
|
the same, adjusting the labels contents to the left:
|box|
box := DialogBox new.
(box addTextLabel:'hello') adjust:#left.
box addAbortButton;
addOkButton;
open
|
with modified buttons:
|box|
box := DialogBox new.
(box addTextLabel:'are you certain ?') adjust:#left.
box addAbortButtonLabelled:'not really'.
(box addOkButtonLabelled:'yes, absolutely')
activeBackgroundColor:Color red.
box open
|
mswindows style (different up/down bitmaps in buttons):
((try tabbing ...)
|b box|
box := DialogBox new.
(box addTextLabel:'are you certain ?') adjust:#left.
b := Button new.
b activeLogo:(Image fromFile:'cancel_down.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b passiveLogo:(Image fromFile:'cancel_up.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b focusLogo:(Image fromFile:'cancel_focus.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b beImageButton.
box addAbortButton:b.
b := Button new.
b activeLogo:(Image fromFile:'ok_down.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b passiveLogo:(Image fromFile:'ok_up.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b focusLogo:(Image fromFile:'ok_focus.bmp' inPackage:'stx:goodies/bitmaps/winImages').
b beImageButton.
box addOkButton:b.
box open
|
two textlabels:
DialogBox new
addTextLabel:'hello';
addTextLabel:'world';
addAbortButton;
addOkButton;
open
|
fixing the dialogs size (suppres it calculating its size from the
preferredExtents of its components):
DialogBox new
label:'a simple dialog';
addTextLabel:'hello';
addAbortButton;
addOkButton;
extent:200@200;
sizeFixed:true;
open
|
asking the box if it was closed via ok:
(DialogBox new
label:'a simple dialog';
addTextLabel:'hello';
addAbortButton;
addOkButton;
extent:200@200;
sizeFixed:true;
open
) accepted ifTrue:[
Transcript showCR:'yes'
] ifFalse:[
Transcript showCR:'no'
]
|
textLabels are not limited to strings (although, the name which is
used for ST-80 compatibility, suggests it):
DialogBox new
addTextLabel:(Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages');
addOkButton;
open
|
DialogBox new
addTextLabel:'hello';
addTextLabel:((Image fromFile:'garfield.gif' inPackage:'stx:goodies/bitmaps/gifImages')
magnifiedTo:200@150);
addTextLabel:'world';
addAbortButton;
addOkButton;
open
|
adding an input field (on a string model):
|stringModel|
stringModel := '' asValue.
(DialogBox new
addTextLabel:'Please enter a string:';
addInputFieldOn:stringModel;
addAbortButton;
addOkButton;
open
) accepted ifTrue:[
Transcript showCR:'entered: ', stringModel value
]
|
multiple input fields (notice, that the dialog connects the fields
in a group, so stepping is allowed via Cursor and Return keys):
|firstName lastName|
firstName := '' asValue.
lastName := '' asValue.
(DialogBox new
addTextLabel:'Please enter your name:';
addInputFieldOn:firstName;
addVerticalSpace;
addInputFieldOn:lastName;
addAbortButton;
addOkButton;
open
) accepted ifTrue:[
Transcript showCR:'entered: ', firstName value , ' ' , lastName value
]
|
of course, the model may contain a value initially:
|firstName lastName p line i name|
firstName := '' asValue.
lastName := '' asValue.
p := PipeStream readingFrom:'finger ' , OperatingSystem getLoginName.
p notNil ifTrue:[
line := p nextLine.
(i := line findString:'Name:') ~~ 0 ifTrue:[
name := line copyFrom:(i + 'Name:' size).
] ifFalse:[
(i := line findString:'real life:') == 0 ifTrue:[
line := p nextLine.
].
(i := line findString:'real life:') ~~ 0 ifTrue:[
name := line copyFrom:(i + 'real life:' size).
]
].
name notNil ifTrue:[
firstName value: name asCollectionOfWords first.
lastName value: name asCollectionOfWords last.
Transcript showCR:'initially ' , firstName value , ' ' , lastName value.
].
p close.
].
(DialogBox new
addTextLabel:'Please enter your name:';
addInputFieldOn:firstName;
addVerticalSpace;
addInputFieldOn:lastName;
addAbortButton;
addOkButton;
open
) accepted ifTrue:[
Transcript showCR:'entered: ', firstName value , ' ' , lastName value
]
|
validated password entry:
|box firstEntry secondEntry|
firstEntry := '' asValue.
secondEntry := '' asValue.
box := DialogBox new.
(box addTextLabel:'Please enter your secret:') adjust:#left.
(box addInputFieldOn:firstEntry) passwordCharacter:$*.
box addVerticalSpace.
(box addInputFieldOn:secondEntry) passwordCharacter:$*.
box addAbortButton.
box addOkButton.
box open.
box accepted ifTrue:[
firstEntry value ~= secondEntry value ifTrue:[
Transcript showCR:'wrong input - try again'
] ifFalse:[
Transcript showCR:'entered: ', firstEntry value
]
]
|
input fields with a label:
|box firstNameHolder middleNameHolder lastNameHolder|
firstNameHolder := 'John' asValue.
middleNameHolder := 'F' asValue.
lastNameHolder := 'Peters' asValue.
box := DialogBox new.
box
addLabelledInputField:'first name:'
adjust:#right
on:firstNameHolder
tabable:true
separateAtX:0.4.
box
addLabelledInputField:'middle initial:'
adjust:#right
on:middleNameHolder
tabable:true
separateAtX:0.4.
box
addLabelledInputField:'last name:'
adjust:#right
on:lastNameHolder
tabable:true
separateAtX:0.4.
box addOkButton.
box open.
|
constructing a dialog from other elements:
adding a fileSelectionList:
(since the dialog adds the component with its preferred extent,
ignoring the 300-height, this looks ugly ...
... especially when resized vertically)
|top l scr fileName|
fileName := '' asValue.
top := DialogBox new.
l := FileSelectionList new.
l useIndex:false.
l doubleClickAction:[:name | top okPressed].
l action:[:name | fileName value:name].
scr := ScrollableView forView:l.
scr extent:(1.0 @ 300).
top addComponent:scr.
top addAbortButton; addOkButton.
top openModal.
top accepted ifTrue:[
Transcript show:'fileName: '; showCR:fileName value storeString.
]
|
same, looks better, since the height is made larger (not using
fileLists preferredExtent):
|top l scr fileName|
fileName := '' asValue.
top := DialogBox new.
l := FileSelectionList new.
l useIndex:false.
l doubleClickAction:[:name | top okPressed].
l action:[:name | fileName value:name].
scr := ScrollableView forView:l.
top addComponent:scr withExtent:300@300.
top addAbortButton; addOkButton.
top openModal.
top accepted ifTrue:[
Transcript show:'fileName: '; showCR:fileName value storeString.
]
|
again, setting the boxes initial size and fixing it
(let it ignore the components' preferredExtent):
|top fixFrame l scr fileName|
fileName := '' asValue.
top := DialogBox new.
top extent:300@300.
fixFrame := View new.
fixFrame extent:(1.0 @ 300).
l := FileSelectionList new.
l useIndex:false.
l doubleClickAction:[:name | top okPressed].
l action:[:name | fileName value:name].
scr := ScrollableView forView:l.
scr origin:0.0@0.0 corner:1.0@1.0.
fixFrame add:scr.
top addComponent:fixFrame.
top addAbortButton; addOkButton.
top openModal.
top accepted ifTrue:[
Transcript show:'fileName: '; showCR:fileName value storeString.
]
|
adding a panel with checkBoxes:
|top panel b value1 value2 value3 value4|
value1 := true asValue.
value2 := false asValue.
value3 := false asValue.
value4 := true asValue.
top := DialogBox new.
top extent:200@300.
panel := VerticalPanelView new.
b := CheckBox on:value1. b label:'check1'.
panel addSubView:b.
b := CheckBox on:value2. b label:'check2'.
panel addSubView:b.
b := CheckBox on:value3. b label:'check3'.
panel addSubView:b.
b := CheckBox on:value4. b label:'check4'.
panel addSubView:b.
top addComponent:panel.
top addAbortButton; addOkButton.
top open.
top accepted ifTrue:[
Transcript show:'value1: '; showCR:value1 value.
Transcript show:'value2: '; showCR:value2 value.
Transcript show:'value3: '; showCR:value3 value.
Transcript show:'value4: '; showCR:value4 value.
]
|
same, using a more convenient interface:
|box value1 value2 value3 value4|
value1 := true asValue.
value2 := false asValue.
value3 := false asValue.
value4 := true asValue.
box := DialogBox new.
box extent:200@300.
box addCheckBox:'check1' on:value1.
box addVerticalSpace.
box addCheckBox:'check2' on:value2.
box addVerticalSpace.
box addCheckBox:'check3' on:value3.
box addVerticalSpace.
box addCheckBox:'check4' on:value4.
box addAbortButton; addOkButton.
box open.
box accepted ifTrue:[
Transcript show:'value1: '; showCR:value1 value.
Transcript show:'value2: '; showCR:value2 value.
Transcript show:'value3: '; showCR:value3 value.
Transcript show:'value4: '; showCR:value4 value.
]
|
same, using an even better interface:
|box values labels|
values := #(true false false true) collect:[:val | val asValue].
labels := #('check1' 'check2' 'check3' 'check4').
box := Dialog new.
box
addColumn:(1 to:labels size)
fromX:0.0
toX:1.0
collect:[:index | CheckBox label:(labels at:index) model:(values at:index)]
tabable:true.
box addAbortButton; addOkButton.
box open.
box accepted ifTrue:[
values with:labels do:[:val :lbl |
Transcript show:(lbl , ': '); showCR:val value.
]
]
|
adding two panels in a frame:
|box frame vPanel1 vPanel2 m1 m2 m3 m4 chk ef|
box := Dialog new.
box label:'example'.
frame := FramedBox label:'frame'.
vPanel1 := VerticalPanelView origin:0.0@0.0 corner:0.5@1.0 in:frame.
vPanel1 horizontalLayout:#leftSpace.
vPanel1 verticalLayout:#spreadSpace.
vPanel2 := VerticalPanelView origin:0.5@0.0 corner:1.0@1.0 in:frame.
vPanel2 horizontalLayout:#leftSpace.
vPanel2 verticalLayout:#spreadSpace.
m1 := true asValue.
m2 := true asValue.
m3 := true asValue.
m4 := 'hello' asValue.
vPanel1 add:(Label label:'check1').
vPanel1 add:(Label label:'m2').
vPanel1 add:(Label label:'m3').
vPanel1 add:(Label label:'enter').
vPanel1 add:(Label label:'lbl1').
vPanel1 add:(Label label:'lbl2').
vPanel2 add:(chk := CheckToggle on:m1).
box makeTabable:chk.
vPanel2 add:(chk := CheckToggle on:m2).
box makeTabable:chk.
vPanel2 add:(chk := CheckToggle on:m3).
box makeTabable:chk.
vPanel2 add:(chk := CheckToggle on:m3).
box makeTabable:chk.
vPanel2 add:(chk := CheckToggle on:m3).
box makeTabable:chk.
vPanel2 add:(ef := EditField on:m4).
ef immediateAccept:true.
box makeTabable:ef.
box addComponent:frame.
box addAbortButton; addOkButton.
box openModal.
box accepted ifTrue:[
Transcript showCR:'accepted with:'.
Transcript showCR:' m1: ' , m1 value printString.
Transcript showCR:' m2: ' , m2 value printString.
Transcript showCR:' m3: ' , m3 value printString.
Transcript showCR:' m4: ' , m4 value printString.
]
|
a full example (combined settings dialog - as in launcher):
|box warnSTX allowUnderscore immutableArrays logDoits
listOfLanguages listOfStyles styleNames
frame panel c resourceDir dir |
warnSTX := Compiler warnSTXSpecials asValue.
allowUnderscore := Compiler allowUnderscoreInIdentifier asValue.
immutableArrays := Compiler arraysAreImmutable asValue.
logDoits := Smalltalk logDoits asValue.
listOfLanguages := SelectionInList with:#('english'
'french'
'german'
'italian'
'spanish'
).
listOfLanguages selection:(Language asString).
resourceDir := Smalltalk getSystemFileName:'resources'.
dir := FileDirectory directoryNamed:resourceDir.
styleNames := dir select:[:aFileName | aFileName endsWith:'.style'].
styleNames := styleNames collect:[:aFileName | aFileName copyWithoutLast:6].
listOfStyles := SelectionInList with:styleNames sort.
listOfStyles selection:(View defaultStyle asString).
box := Dialog new.
box label:'Settings'.
frame := FramedBox label:'Compiler'.
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
panel horizontalLayout:#leftSpace.
panel add:((CheckBox on:warnSTX) label:'warn about ST/X language extensions'; resize).
panel add:((CheckBox on:allowUnderscore) label:'allow underscore in identifiers'; resize).
panel add:((CheckBox on:immutableArrays) label:'literal arrays are immutable'; resize).
box addComponent:frame.
frame := FramedBox label:'Misc'.
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
panel horizontalLayout:#leftSpace.
panel add:((CheckBox on:logDoits) label:'log doIts in changes file'; resize).
box addComponent:frame.
frame := FramedBox label:'Language'.
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
panel horizontalLayout:#leftSpace.
panel add:((PopUpList on:listOfLanguages) width:0.5).
box addComponent:frame.
frame := FramedBox label:'Style'.
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:frame.
panel horizontalLayout:#leftSpace.
panel add:((PopUpList on:listOfStyles) width:0.5).
box addComponent:frame.
box addAbortButton; addOkButton.
box showAtPointer.
box accepted ifTrue:[
Transcript topView withCursor:Cursor wait do:[
Compiler warnSTXSpecials:warnSTX value.
Compiler allowUnderscoreInIdentifier:allowUnderscore value.
Compiler arraysAreImmutable:immutableArrays value.
Smalltalk logDoits:logDoits value.
Transcript showCR:'change language to ' , listOfLanguages selection , ' ...'.
Smalltalk at:#Language put:listOfLanguages selection asSymbol.
Smalltalk changed:#Language.
ResourcePack flushCachedResourcePacks.
Transcript showCR:'change style to ' , listOfStyles selection , ' ...'.
View defaultStyle:listOfStyles selection asSymbol.
]
]
|
an example from Hopkins/Horan:
|aText index|
aText := 'Smalltalk/X: An Introduction to Application Development' asText.
index := aText findString:'Smalltalk/X' startingAt:1.
aText emphasizeFrom:index
to:'Smalltalk/X' size + index - 1
with:#bold.
index := aText findString:'Introduction' startingAt:index.
aText emphasizeFrom:index
to:'Introduction' size + index - 1
with:#italic.
Dialog warn:aText
|
the same, with colors:
|aText index|
aText := 'Smalltalk/X: An Introduction to Application Development' asText.
index := aText findString:'Smalltalk/X' startingAt:1.
aText emphasizeFrom:index
to:'Smalltalk/X' size + index - 1
with:(Array with:#bold with:#underline with:(#color->Color red)).
index := aText findString:'Introduction' startingAt:index.
aText emphasizeFrom:index
to:'Introduction' size + index - 1
with:#italic.
Dialog warn:aText
|
|