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