|
Class: OptionBox
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--TopView
|
+--StandardSystemView
|
+--ModalBox
|
+--DialogBox
|
+--OptionBox
- Package:
- stx:libwidg
- Category:
- Views-DialogBoxes
- Version:
- rev:
1.83
date: 2017/11/28 13:33:49
- user: cg
- file: OptionBox.st directory: libwidg
- module: stx stc-classLibrary: libwidg
- Author:
- Claus Gittinger
CAVEAT: this is a leftover - functionality has been merged into DialogBox
PLEASE use one of the `Dialog chooseXXX' methods instead of OptionBox.
Historic note:
originally, ST/X had separate classes for the various entry methods;
there were YesNoBox, EnterBox, InfoBox and so on.
In the meantime, the DialogBox class (and therefore its alias: Dialog)
is going to duplicate most functionality found in these classes.
In the future, those existing subclasses' functionality is going to
be moved fully into Dialog, and the subclasses will be replaced by dummy
delegators. (They will be kept for backward compatibility, though).
OptionBoxes are like YesNoBoxes but with as many buttons as you like;
this will finally be a superclass of WarnBox and YesNoBox - or maybe merged
all into DialogBox..
Use them for multiway questions.
For a consistent user interface, the rightmost button is the default return
button (i.e. pressing return in the box performs this buttons function).
DialogBox
easy startup
-
forRequest: title label: label image: anImage buttonLabels: labels values: values default: defaultValue
-
create a new optionBox and return it.
Does not open the box.
-
request: title buttonLabels: labels values: values
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled
usage example(s):
OptionBox
request:'please select any'
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
|
-
request: title buttonLabels: labels values: values default: defaultValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled.
usage example(s):
OptionBox
request:'please select'
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
default:3
|
-
request: title label: label buttonLabels: labels values: values
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled
usage example(s):
OptionBox
request:'please select'
label:'select any'
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
|
-
request: title label: label buttonLabels: labels values: values default: defaultValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled
usage example(s):
OptionBox
request:'please select'
label:'select any'
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
default:3
|
-
request: title label: label buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if canceled.
usage example(s):
OptionBox
request:'please select'
label:'select any'
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
default:3
onCancel:2
|
-
request: title label: label image: anImage buttonLabels: labels values: values
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil, if canceled.
usage example(s):
OptionBox
request:'please select'
label:'select any'
image:(WarningBox iconBitmap)
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
|
-
request: title label: label image: anImage buttonLabels: labels values: values default: defaultValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled.
usage example(s):
OptionBox
request:'please select'
label:'select any'
image:(WarningBox iconBitmap)
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
default:3
|
-
request: title label: label image: anImage buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if canceled.
usage example(s):
OptionBox
request:'please select'
label:'select any'
image:(WarningBox iconBitmap)
buttonLabels:#('one' 'two' 'three')
values:#(1 2 3)
default:3
onCancel:nil
|
instance creation
-
title: titleString numberOfOptions: nOptions
-
create a new optionBox with title, aTitleString and nOptions options
obsolete
-
forRequest: title label: label form: anImage buttonLabels: labels values: values default: defaultValue
-
create a new optionBox and return it.
Does not open the box.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: title label: label form: aForm buttonLabels: labels values: values
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil, if canceled.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: title label: label form: aForm buttonLabels: labels values: values default: defaultValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return nil if canceled.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: title label: label form: aForm buttonLabels: labels values: values default: defaultValue onCancel: cancelValue
-
create a new optionBox, open it modal and return the value of
the corresponding values collection. Return cancelValue if canceled.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
accessing
-
action: actionBlock
-
define a single the action for all buttons.
The action will be evaluated with the button index as argument.
-
actions: actionBlocks
-
define the actions
-
buttonTitles: titles actions: actionBlocks
-
define both button titles and actions
-
defaultButtonIndex: index
-
define which button is the default (i.e. return-) button.
By default, no returnButton is setup. The argument must be an
index 1..nButtons, or nil
-
numberOfOptions
-
return the number of options
-
numberOfOptions: nOptions
-
set the number of options - this is a private interface
accessing-components
-
buttons
-
return the buttons collection
-
labelPanel
-
accessing-look
-
buttonTitles: titles
-
set the button titles
-
form: aFormOrImage
-
historical leftover - define a form to be displayed left of the title
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
formLabel
-
return the label-view which displays a bitmap
-
image: aFormOrImage
-
set the image shown in the label-view
-
textLabel
-
return the label-view which displays a message string
-
title: aString
-
set the boxes title
-
title: aString numberOfOptions: nOptions
-
set the boxes title and number of options
events
-
keyPress: aKey x: x y: y
-
return-key duplicates ok-function if acceptReturnAsOK is true
initialization
-
initFormBitmap
-
-
initInfoBitmap
-
-
initWarnBitmap
-
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display
-
initYesNoBitmap
-
-
initialize
-
formLabel origin:(mm @ mm).
queries
-
preferredExtent
-
return a size to make everything fit into myself
usage example(s):
If I have an explicit preferredExtent..
|
usage example(s):
If I have a cached preferredExtent value..
|
|box|
box := OptionBox title:'hello' numberOfOptions:4.
box showAtPointer
|
|box|
box := OptionBox title:'hello' numberOfOptions:3.
box buttonTitles:#('one' 'two' 'three').
box showAtPointer
|
performing an action:
|box|
box := OptionBox title:'hello' numberOfOptions:3.
box buttonTitles:#('one' 'two' 'three').
box action:[:which | Transcript show:'button ';
show: which;
showCR:' was pressed'].
box showAtPointer
|
returning a value:
|what|
what := OptionBox
request:('text has not been accepted.\\Your modifications will be lost when continuing.') withCRs
label:' Attention'
image:(WarningBox iconBitmap)
buttonLabels:#('Abort' 'Accept' 'Continue')
values:#(#abort #accept #continue).
Transcript showCR:what.
|
use callBack-hook to intercept creation:
|what|
AboutToOpenBoxNotificationSignal handle:[:ex |
|box|
box := ex parameter.
box verticalPanel
add:(CheckBox label:'Do no show this Dialog again.'
model:false asValue).
ex proceed.
] do:[
what := OptionBox
request:('bla bla bla bla.\\You must bla bla bla!') withCRs
label:' Attention'
image:(WarningBox iconBitmap)
buttonLabels:#('Abort' 'Accept' 'Continue')
values:#(#abort #accept #continue)
default:#continue.
].
Transcript showCR:what.
|
|