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