EnterBox2.st
changeset 0 e6a541c1c0eb
child 3 9d7eefb5e69f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EnterBox2.st	Fri Jul 16 11:44:44 1993 +0200
@@ -0,0 +1,93 @@
+"
+ COPYRIGHT (c) 1991-93 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.
+"
+
+EnterBox subclass:#EnterBox2
+       instanceVariableNames:'okButton2 okAction2'
+       classVariableNames:''
+       poolDictionaries:''
+       category:'Views-Interactors'
+!
+
+EnterBox2 comment:'
+
+COPYRIGHT (c) 1991-93 by Claus Gittinger
+              All Rights Reserved
+
+like an EnterBox but with 2 action buttons.
+
+%W% %E%
+
+written Sep 91 by claus
+'!
+
+!EnterBox2 class methodsFor:'instance creation'!
+
+title:titleString okText1:text1 okText2:text2 abortText:abortText
+                  action1:block1 action2:block2
+    "create and return a new EnterBox-with-2 buttons
+     and define its text, button-labels and actions"
+
+    ^ (super title:titleString 
+            okText:text1 
+         abortText:abortText
+            action:block1) okText2:text2 action2:block2
+! !
+
+!EnterBox2 methodsFor:'initialization'!
+
+initialize
+    super initialize.
+
+    okButton2 := Button label:'' 
+                       action:[
+                                okButton2 turnOffWithoutRedraw.
+                                self ok2Pressed
+                              ] 
+                           in:buttonPanel.
+    okButton isReturnButton:false.
+    okButton2 isReturnButton:true.
+    self resize.
+    enterField leaveAction:[:key | self ok2Pressed]
+! !
+
+!EnterBox2 methodsFor:'accessing'!
+
+okText2:aString action2:aBlock
+    "set the text to be displayed in the 2nd ok-button,
+     and its action"
+
+    self okText2:aString.
+    okAction2 := aBlock
+!
+
+okText2:aString
+    "set the text to be displayed in the 2nd ok-button"
+
+    okButton2 label:aString.
+    okButton2 resize.
+    self resize
+!
+
+action2:aBlock
+    "set the action to be performed when user presses the 2nd ok-button;
+     aBlock must be nil or a block with one argument "
+
+    okAction2 := aBlock
+! !
+
+!EnterBox2 methodsFor:'user interaction'!
+
+ok2Pressed
+    "user pressed 2nd ok button - evaluate action"
+
+    self hideAndEvaluate:okAction2
+! !