EnterBox2.st
changeset 8 82e87dc3540e
parent 5 7b4fb1b170e5
child 38 4b9b70b2cc87
--- a/EnterBox2.st	Sat Dec 11 02:51:34 1993 +0100
+++ b/EnterBox2.st	Mon Dec 13 18:06:07 1993 +0100
@@ -24,7 +24,7 @@
 
 like an EnterBox but with 2 action buttons.
 
-$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.3 1993-10-13 02:47:37 claus Exp $
+$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.4 1993-12-13 17:05:47 claus Exp $
 
 written Sep 91 by claus
 '!
@@ -59,6 +59,16 @@
     enterField leaveAction:[:key | self ok2Pressed]
 ! !
 
+!EnterBox2 methodsFor:'realization'!
+
+positionOffset
+    "return the delta, by which the box should be displayed
+     from the mouse pointer. Value returned here makes
+     okButton appear under the cursor"
+
+    ^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2)
+! !
+
 !EnterBox2 methodsFor:'accessing'!
 
 okText2:aString action2:aBlock
@@ -72,9 +82,11 @@
 okText2:aString
     "set the text to be displayed in the 2nd ok-button"
 
-    okButton2 label:aString.
-    okButton2 resize.
-    self resize
+    aString ~= okButton2 label ifTrue:[
+        okButton2 label:aString.
+        okButton2 resize.
+        self resize
+    ]
 !
 
 action2:aBlock