DialogBoxes positionOffset now handles all common cases
authorClaus Gittinger <cg@exept.de>
Thu, 16 Jan 1997 22:02:25 +0100
changeset 953 050fba15277a
parent 952 9accd6d8221c
child 954 3c86fe074772
DialogBoxes positionOffset now handles all common cases
DialogBox.st
EnterBox2.st
OptBox.st
OptionBox.st
--- a/DialogBox.st	Thu Jan 16 20:37:34 1997 +0100
+++ b/DialogBox.st	Thu Jan 16 22:02:25 1997 +0100
@@ -5135,24 +5135,38 @@
 
 positionOffset
     "return the delta, by which the box should be displayed
-     from the mouse pointer. Value returned here makes center of
-     okButton appear under the cursor"
-
-    okButton isNil ifTrue:[
-        ^ super positionOffset
+     from the mouse pointer. Here, an offset is returned, which
+     makes the center of the first return-Button in the panel
+     appear under the cursor. If there is no such button,
+     use my superclasses offset."
+
+    |idx butt buttons|
+
+    buttonPanel notNil ifTrue:[
+        buttons := buttonPanel subViews.
+        buttons size > 0 ifTrue:[
+            idx := buttons findFirst:[:b | b isReturnButton].
+            idx ~~ 0 ifTrue:[
+                butt := buttons at:idx.
+
+                "get our size (preferredExtent) and compute
+                 origin and extent of buttonPanel and okButton.
+                 This is normally done on view realization."
+
+                self resize.
+                buttonPanel pixelOrigin:buttonPanel computeOrigin.
+                buttonPanel pixelExtent:buttonPanel computeExtent.
+                buttonPanel setChildPositionsIfChanged.
+
+                ^ (butt originRelativeTo:self) + (butt extent // 2)
+            ]
+        ]
     ].
 
-    "get our size (preferredExtent) and compute
-     origin and extent of buttonPanel and okButton.
-     This is normally done on view realization."
-
-    self resize.
-    buttonPanel pixelOrigin:buttonPanel computeOrigin.
-    buttonPanel pixelExtent:buttonPanel computeExtent.
-    buttonPanel setChildPositionsIfChanged.
-    ^ (okButton originRelativeTo:self) + (okButton extent // 2)
+    ^ super positionOffset
 
     "Modified: 3.1.1997 / 10:41:58 / stefan"
+    "Modified: 16.1.1997 / 22:00:23 / cg"
 !
 
 preferredExtent 
@@ -5309,6 +5323,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.98 1997-01-16 10:45:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.99 1997-01-16 21:02:25 cg Exp $'
 ! !
 DialogBox initialize!
--- a/EnterBox2.st	Thu Jan 16 20:37:34 1997 +0100
+++ b/EnterBox2.st	Thu Jan 16 22:02:25 1997 +0100
@@ -77,7 +77,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.17 1996-05-31 20:17:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.18 1997-01-16 21:01:27 cg Exp $'
 ! !
 
 !EnterBox2 methodsFor:'accessing'!
@@ -129,17 +129,6 @@
     "Modified: 31.5.1996 / 21:55:57 / cg"
 ! !
 
-!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"
-
-    buttonPanel setChildPositionsIfChanged.
-    ^ (okButton2 originRelativeTo:self) + (okButton2 extent // 2)
-! !
-
 !EnterBox2 methodsFor:'user interaction'!
 
 keyPress:aKey x:x y:y
--- a/OptBox.st	Thu Jan 16 20:37:34 1997 +0100
+++ b/OptBox.st	Thu Jan 16 22:02:25 1997 +0100
@@ -363,32 +363,6 @@
 
 !OptionBox methodsFor:'queries'!
 
-positionOffset
-    "return the delta, by which the box should be displayed
-     from the mouse pointer. Value returned here makes
-     the return-button appear under the cursor"
-
-    |idx butt|
-
-    "get our size (preferredExtent) and compute
-     origin and extent of buttonPanel and okButton.
-     This is normally done on view realization."
-
-    self resize.
-    buttonPanel pixelOrigin:buttonPanel computeOrigin.
-    buttonPanel pixelExtent:buttonPanel computeExtent.
-    buttonPanel setChildPositionsIfChanged.
-
-    idx := buttons findFirst:[:b | b isReturnButton].
-    idx ~~ 0 ifTrue:[
-        butt := buttons at:idx.
-        ^ (butt originRelativeTo:self) + (butt extent // 2)
-    ].
-    ^ self extent // 2
-
-    "Modified: 16.1.1997 / 20:36:38 / cg"
-!
-
 preferredExtent 
     "return a size to make everything fit into myself"
 
@@ -424,5 +398,5 @@
 !OptionBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/OptBox.st,v 1.38 1997-01-16 19:37:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/OptBox.st,v 1.39 1997-01-16 21:01:47 cg Exp $'
 ! !
--- a/OptionBox.st	Thu Jan 16 20:37:34 1997 +0100
+++ b/OptionBox.st	Thu Jan 16 22:02:25 1997 +0100
@@ -363,32 +363,6 @@
 
 !OptionBox methodsFor:'queries'!
 
-positionOffset
-    "return the delta, by which the box should be displayed
-     from the mouse pointer. Value returned here makes
-     the return-button appear under the cursor"
-
-    |idx butt|
-
-    "get our size (preferredExtent) and compute
-     origin and extent of buttonPanel and okButton.
-     This is normally done on view realization."
-
-    self resize.
-    buttonPanel pixelOrigin:buttonPanel computeOrigin.
-    buttonPanel pixelExtent:buttonPanel computeExtent.
-    buttonPanel setChildPositionsIfChanged.
-
-    idx := buttons findFirst:[:b | b isReturnButton].
-    idx ~~ 0 ifTrue:[
-        butt := buttons at:idx.
-        ^ (butt originRelativeTo:self) + (butt extent // 2)
-    ].
-    ^ self extent // 2
-
-    "Modified: 16.1.1997 / 20:36:38 / cg"
-!
-
 preferredExtent 
     "return a size to make everything fit into myself"
 
@@ -424,5 +398,5 @@
 !OptionBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.38 1997-01-16 19:37:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.39 1997-01-16 21:01:47 cg Exp $'
 ! !