eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'YesNoBox':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: YesNoBox


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--TopView
                  |
                  +--StandardSystemView
                     |
                     +--ModalBox
                        |
                        +--DialogBox
                           |
                           +--InfoBox
                              |
                              +--WarningBox
                                 |
                                 +--YesNoBox

Package:
stx:libwidg
Category:
Views-DialogBoxes
Version:
rev: 1.65 date: 2018/11/09 23:37:54
user: cg
file: YesNoBox.st directory: libwidg
module: stx stc-classLibrary: libwidg
Author:
Claus Gittinger

Description:


aHistoric 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).

 New applications should use corresponding confirmation
 methods from DialogBox.

 This class implements yes-no boxes by adding another (no-) Button to the WarnBox-View.
 They are created with:

     aBox := YesNoBox title:'some title'.
     aBox okAction:[ .. some action to be performed when ok is pressed ].

 and finally shown with:

     aBox showAtPointer

 The default box shows 'yes' and 'no' in its buttons; this can be changed with:

     aBox yesText:'some string'.
     aBox noText:'some string'.

 There is also protocol to set both button titles in one message.
 Also, the action associated to the noButton can be changed.

 For very simple yes/no queries, you can also use the much simpler confirm:.
 Since implemented in Object, everyone understands confirm. You can pass
 a question message (but not change the buttons labels).
 Use is:
     self confirm:'some question'
 and will return true or false.

 For compatibility with ST-80, use:
     Dialog confirm:'hello'


Related information:

    DialogBox
    EnterBox

Class protocol:

icon bitmap
o  iconBitmap
return the bitmap shown as icon in my instances.
This is the default image; you can overwrite this in a concrete
instance with the #image: message.

instance creation
o  title: titleString yesText: yesString noText: noString
return a new YesNoBox with title, and buttonLabels yesString/noString

styles
o  updateStyleCache
extract values from the styleSheet and cache them in class variables.
Here, the cached infoBitmap is simply flushed.


Instance protocol:

initialization
o  initialize
looks better; should it come from the StyleSheet ?

queries
o  beepWhenOpening

o  computePreferredExtent
compute the boxes preferredExtent from the components' sizes

startup
o  confirm
open the receiver and return true for yes, false for no.
This is an easier interface to use, since no action blocks
have to be defined. The title is used as previously defined.

usage example(s):

     YesNoBox new confirm

o  confirm: aString
open a modal yes-no dialog.
Return true for yes, false for no.
This is an easier interface to use, since no action blocks have to be defined.

usage example(s):

     YesNoBox new confirm:'really?'
     YesNoBox confirm:'really?'
     self confirm:'really?'

    for ST-80 compatibility, you should use Dialogs confirm
    (which simply forwards the request to the YesNoBox anyway):

     Dialog confirm:'really?'

user interaction
o  noPressed
user pressed the no-button;
hide myself and evaluate the action


Examples:


Notice, the preferred use is via the DialogBox class messages, such as
    Dialog confirm:'Coffee ?'
    Dialog confirmWithCancel:'Coffee ?'
these (DialogBox) mesages are compatible with VW and should therefore be used for portability. Direct reference to YesNoBox is only required for highly specialized boxes. Examples:
    |aBox|

    aBox := YesNoBox title:'Coffee or tee ?'.
    aBox noText:'tee'.
    aBox yesText:'coffee'.
    aBox yesAction:[Transcript showCR:'make coffee'].
    aBox noAction:[Transcript showCR:'make tee'].
    aBox showAtPointer.
or, shorter:
    |aBox|

    aBox := YesNoBox new.
    aBox title:'Coffee or Tee?'
         yesAction:[Transcript showCR:'make coffee']
         noAction:[Transcript showCR:'make tee'].
    aBox yesText:'Coffee' noText:'Tee'.
    aBox showAtPointer
Also, have a look at the inherited protocol; for example, this allows changing the bitmap (default: a question mark) and other properties. If the box is needed to ask for a simple boolean, you can also use the #confirm method, to bring up a box, let it ask for something and return true or false. Example:
    |box value|

    box := YesNoBox new.
    value := box confirm:'yes or no:'.
    value ifTrue:[
        Transcript showCR:'yes'
    ] ifFalse:[
        Transcript showCR:'no'
    ]
of course, this can also be written shorter as:
    (YesNoBox new confirm:'yes or no:') ifTrue:[
        Transcript showCR:'yes'
    ] ifFalse:[
        Transcript showCR:'no'
    ]
or:
    (Dialog confirm:'yes or no:') ifTrue:[
        Transcript showCR:'yes'
    ] ifFalse:[
        Transcript showCR:'no'
    ]
or even:
    Transcript showCR:(
        (Dialog confirm:'yes or no:')   
            ifTrue:['yes'] 
            ifFalse:['no'])


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 06:14:39 GMT