|
Class: OptionBox
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--TopView
|
+--StandardSystemView
|
+--ModalBox
|
+--DialogBox
|
+--OptionBox
- Package:
- stx:libwidg
- Category:
- Views-DialogBoxes
- Version:
- rev:
1.92
date: 2023/03/23 17:19:54
- user: cg
- file: OptionBox.st directory: libwidg
- module: stx stc-classLibrary: libwidg
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).
Description:
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 (last) button should be the default return
button (i.e. pressing return in the box performs this buttons function).
However, this is reversed automatically if the viewStyle says so (Windows vs. OSX vs. Linux),
so the programmer MUST always put the no-actions (i.e. cancel) first and the ok-actions (yes) last.
copyrightCOPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
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.
-
forRequest: title label: label image: anImage buttonLabels: labels values: values default: defaultValue helpTexts: helpTextsOrNil
-
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
|
-
request: title label: label image: anImage buttonLabels: labels values: values default: defaultValue onCancel: cancelValue helpTexts: helpTextsOrNil
-
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
-
create a new optionBox with title, aTitleString
-
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 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: aStringOrStringCollection
-
set the boxes title
-
title: aString numberOfOptions: nOptions
-
set the boxes title and number of options
help
-
buttonHelpTexts: helpTextsOrNil
-
annotate buttons with help texts.
initialization
-
initFormBitmap
-
-
initInfoBitmap
-
-
initWarnBitmap
-
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display
-
initYesNoBitmap
-
-
initialize
-
formLabel origin:(mm @ mm).
-
initializeButtons
-
no longer make the last button the default!
queries
-
computePreferredExtent
-
return a size to make everything fit into myself
just opening
(not real world examples, as you'd have to ask the box instance about the choice afterwards;
see better usage examples below):
|box|
box := OptionBox title:'hello' numberOfOptions:4.
box showAtPointer
|
|box|
box := OptionBox title:'hello'.
box buttonTitles:#('one' 'two' 'three').
box defaultButtonIndex:3.
box showAtPointer
|
showing a long list:
|box|
box := OptionBox title:(1 to:100 collect:#asString) numberOfOptions:3.
box buttonTitles:#('one' 'two' 'three').
box defaultButtonIndex:3.
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.
|
|