eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TextBox':

Home

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

Class: TextBox


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--TopView
                  |
                  +--StandardSystemView
                     |
                     +--ModalBox
                        |
                        +--DialogBox
                           |
                           +--EnterBox
                              |
                              +--TextBox
                                 |
                                 +--TextCollectorBox

Package:
stx:libwidg2
Category:
Views-DialogBoxes
Version:
rev: 1.38 date: 2023/11/06 15:14:06
user: cg
file: TextBox.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

Description:


this class implements a pop-up box to enter some text with 2 buttons,
one to cancel, another to start some action.
It is basically an enterBox, but allows entering of more than one line
of text.

copyright

COPYRIGHT (c) 1992 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.

Class protocol:

common dialogs
o  openOn: someText
open a textBox on some text,
return (the possibly modified) text if accepted; nil otherwise.

Usage example(s):

     TextBox openOn:'hello'

o  openOn: someText title: titleString
open a textBox on some text, the titleString is shown above the text area as information
return (the possibly modified) text if accepted; nil otherwise.

Usage example(s):

     TextBox openOn:'hello' title:'hi there'
     TextBox openOn:'hello' title:'hi there
this is a very long title
but only the first line is shown in the
caption.
'

o  openOn: someText title: titleString readOnly: readOnly
open a textBox on some text,
return (the possibly modified) text if accepted; nil otherwise.

Usage example(s):

     TextBox openOn:'hello' title:'hi there' readOnly:true
     TextBox openOn:'hello' title:'hi there' readOnly:false

o  openOn: someText title: titleString windowTitle: windowTitle readOnly: readOnly
open a textBox on some text, the optional titleString is shown as label
above the text areay. The optional windowTitle is used as title in the caption.
return (the possibly modified) text if accepted; nil otherwise.

Usage example(s):

     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:false
     TextBox openOn:'hello' title:'hi there' windowTitle:nil readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:'some Box' readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:nil readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:'foo' readOnly:false

defaults
o  defaultExtent
(comment from inherited method)
return the default extent of my instances.
The value returned here is usually ignored, and
the value from preferredExtent taken instead.


Instance protocol:

accessing
o  contents
return my contents (i.e. possibly modified text after accept)

o  contents: newText
set my contents

o  initialText: aString
define the initial text in the texteditor

o  readOnly: aBoolean
make my text readOnly or readWrite

accessing-contents
o  textView
return my textView component

o  textViewClass: aClassToUseForTheTextView
Modified (format): / 15-07-2019 / 16:38:11 / Claus Gittinger

initialization
o  initialize
TextBox new showAtPointer
(TextBox title:'hello') showAtPointer

o  initializeTextView
destroy the old textView if there is one

o  initializeTextViewLayout
kludge: preset extent to something useful since other subviews
depend on it (extent blocks are not evaluated until view is realized)
- avoid visible resizing when realized the first time

o  openOn: someText title: titleString windowTitle: windowTitle readOnly: readOnly
open a textBox on some text, the optional titleString is shown as label
above the text areay. The optional windowTitle is used as title in the caption.
return (the possibly modified) text if accepted; nil otherwise.

Usage example(s):

     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:true
     TextBox openOn:'hello' title:'hi there' windowTitle:'some Box' readOnly:false
     TextBox openOn:'hello' title:'hi there' windowTitle:nil readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:'some Box' readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:nil readOnly:false
     TextBox openOn:'hello' title:nil windowTitle:'foo' readOnly:false

o  title: aString
(comment from inherited method)
set the title to be displayed at top of the enterBox.
This is NOT the window title.

queries
o  computePreferredExtent
return the extent needed to make everything visible


Examples:


Example (using ok-action callBack):
  |textBox|

  textBox := TextBox new.
  textBox title:'enter some text'.
  textBox action:[:text | Transcript showCR:('the entered text was:\' , text) withCRs].
  textBox showAtPointer.
  |textBox|

  textBox := TextBox new.
  textBox title:'some\multiline\title\\enter some text' withCRs.
  textBox action:[:text | Transcript showCR:('the entered text was:\' , text) withCRs].
  textBox showAtPointer.
Example (asking afterwards):
  |textBox|

  textBox := TextBox new.
  textBox title:'enter some text'.
  textBox showAtPointer.
  textBox accepted ifTrue:[
      Transcript showCR:'accepted text is:'.
      Transcript showCR:textBox contents
  ].
Example - readonly text (useful for status display):
  |textBox|

  textBox := TextBox new.
  textBox initialText:('Makefile' asFilename contents).
  textBox title:'Makefile:'.
  textBox readOnly:true.
  textBox noCancel.
  textBox label:'Makefile'.
  textBox extent:(600@250); sizeFixed:true.
  textBox showAtPointer.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 30 Dec 2024 17:56:55 GMT