EnterBox2.st
author Claus Gittinger <cg@exept.de>
Wed, 10 Apr 2002 12:50:18 +0200
changeset 2527 3e7d9eaa347b
parent 2448 425e9a7d369d
child 2697 62d6c6b7a2a2
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
2448
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    13
"{ Package: 'stx:libwidg' }"
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
EnterBox subclass:#EnterBox2
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    16
	instanceVariableNames:'okButton2 okAction2'
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    17
	classVariableNames:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    18
	poolDictionaries:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    19
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
2448
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    22
!EnterBox2 class methodsFor:'documentation'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    23
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    26
 COPYRIGHT (c) 1991 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
    27
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    28
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    36
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    37
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    38
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    39
"
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    40
   Historic note:
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    41
        originally, ST/X had separate classes for the various entry methods;
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    42
        there were YesNoBox, EnterBox, InfoBox and so on.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    43
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    44
        is going to duplicate most funcionality found in these classes.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    45
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    46
        In the future, those existing subclasses' functionality is going to
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    47
        be moved fully into Dialog, and the subclasses will be replaced by dummy
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    48
        delegators. (They will be kept for backward compatibility, though).
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    49
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    50
    An EnterBox2 is like an EnterBox but with 2 action buttons.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    51
    This is used (for example) in the search-boxes, where two ok-buttons
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    52
    'find-previous' and 'find-next' are needed in addition to the abort button.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    53
    The protocol is like that of EnterBox, the additional buttons label
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    54
    can be set with 'okText2:aString' and its action with 'action2:aBlock'.
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    55
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    56
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    57
        Claus Gittinger
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    58
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    59
    [see also:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    60
        DialogBox
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    61
        EnterBox YesNoBox
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    62
        ListSelectionBox FileSelectionBox FileSaveBox
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    63
"
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
    64
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    65
    "Modified: 25.4.1996 / 16:47:41 / cg"
2448
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    66
! !
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    67
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    68
!EnterBox2 class methodsFor:'instance creation'!
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    69
2448
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    70
title:titleString okText1:text1 okText2:text2 abortText:abortText
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    71
		  action1:block1 action2:block2
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    72
    "create and return a new EnterBox-with-2 buttons
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    73
     and define its text, button-labels and actions"
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    74
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    75
    ^ (super title:titleString 
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    76
	    okText:text1 
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    77
	 abortText:abortText
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
    78
	    action:block1) okText2:text2 action2:block2
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 8
diff changeset
    79
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    80
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
!EnterBox2 methodsFor:'accessing'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
action2:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
    "set the action to be performed when user presses the 2nd ok-button;
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    85
     aBlock must be nil or a block with one argument "
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
    okAction2 := aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    90
okText2:aString
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
    "set the text to be displayed in the 2nd ok-button"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    92
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
    aString ~= okButton2 label ifTrue:[
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
	okButton2 label:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
	okButton2 resize.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
	shown ifTrue:[self resize]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
    ]
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    99
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
okText2:aString action2:aBlock
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
    "set the text to be displayed in the 2nd ok-button,
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
     and its action"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
    self okText2:aString.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
    okAction2 := aBlock
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   107
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   108
!EnterBox2 methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   109
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   110
initialize
1764
45ca6b617934 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1760
diff changeset
   111
    <resource: #style (#'dialogBox.okAtLeft')>
45ca6b617934 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1760
diff changeset
   112
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   113
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   114
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   115
    "
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   116
     add a second ok-button (a return button)
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   117
    "
1760
631f902aaabe care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   118
    okButton2 := Button okButton.
2040
7e2052cb0c8c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   119
    (styleSheet at:'dialogBox.okAtLeft' default:false) ifTrue:[
1760
631f902aaabe care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   120
        buttonPanel addSubView:okButton2 before:okButton.
631f902aaabe care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   121
    ] ifFalse:[
631f902aaabe care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   122
        buttonPanel addSubView:okButton2 after:okButton.
631f902aaabe care for styleSheets right-to-left button order.
Claus Gittinger <cg@exept.de>
parents: 953
diff changeset
   123
    ].
95
7535cfca9509 *** empty log message ***
claus
parents: 77
diff changeset
   124
    okButton2 model:self; change:#ok2Pressed.
7535cfca9509 *** empty log message ***
claus
parents: 77
diff changeset
   125
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   126
    "
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   127
     the old (see superclass) ok-button is no longer a return-button
59
450ce95a72a4 *** empty log message ***
claus
parents: 48
diff changeset
   128
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   129
    okButton isReturnButton:false.
48
eabeb474d989 changed cursors
claus
parents: 38
diff changeset
   130
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   131
    enterField leaveAction:[:key | self ok2Pressed]
740
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   132
2d5cb01c7e11 no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   133
    "Modified: 31.5.1996 / 21:55:57 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   134
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   135
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   136
!EnterBox2 methodsFor:'user interaction'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   137
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   138
keyPress:aKey x:x y:y
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   139
    "return-key dublicates ok-function if acceptReturnAsOK is true"
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   140
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   141
    <resource: #keyboard (#Return)>
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   142
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   143
    acceptReturnAsOK ifTrue:[
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   144
        (aKey == #Return) ifTrue:[^ self ok2Pressed]
77
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   145
    ].
565b052f5277 *** empty log message ***
claus
parents: 60
diff changeset
   146
    super keyPress:aKey x:x y:y
490
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   147
08e8adfb783c resources
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   148
    "Modified: 7.3.1996 / 13:16:37 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   150
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   151
ok2Pressed
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   152
    "user pressed 2nd ok button - evaluate action"
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   153
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   154
    okButton2 turnOffWithoutRedraw.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   155
    self hideAndEvaluate:okAction2
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   156
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   157
2448
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
   158
!EnterBox2 class methodsFor:'documentation'!
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
   159
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
   160
version
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
   161
    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.22 2001-10-18 16:49:42 cg Exp $'
425e9a7d369d category included a space
Claus Gittinger <cg@exept.de>
parents: 2040
diff changeset
   162
! !