PopUpMenu.st
changeset 281 0f41c95fa722
parent 258 ae4b8f1a6738
child 284 fb625951b7fc
--- a/PopUpMenu.st	Wed Jan 10 19:54:33 1996 +0100
+++ b/PopUpMenu.st	Wed Jan 10 20:17:31 1996 +0100
@@ -11,11 +11,11 @@
 "
 
 PopUpView subclass:#PopUpMenu
-	 instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels
-                actionLines actionValues hideOnRelease defaultHideOnRelease'
-	 classVariableNames:'DefaultHideOnRelease'
-	 poolDictionaries:''
-	 category:'Views-Menus'
+	instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels
+		actionLines actionValues hideOnRelease defaultHideOnRelease'
+	classVariableNames:'DefaultHideOnRelease'
+	poolDictionaries:''
+	category:'Views-Menus'
 !
 
 !PopUpMenu class methodsFor:'documentation'!
@@ -459,81 +459,106 @@
      Modal - i.e. stay in the menu until finished.
      This is the ST-80 way of launching a menu."
 
+    ^ self startUpAt:nil
+
+    "
+     Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp 
+     Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')
+                                  values:#(foo bar baz)) startUp
+    "
+
+    "Modified: 10.1.1996 / 20:16:40 / cg"
+!
+
+startUpAt:aPoint
+    "start the menu modal - return the selected value,
+     or - if no values where specified - return the index.
+     If nothing was selected, return 0.
+     Modal - i.e. stay in the menu until finished.
+     This is the ST-80 way of launching a menu."
+
     |return rec sel0 sel1 arg|
 
     return := 0.
 
     menuView action:[:selected |
-	|actionIndex value sel retVal|
+        |actionIndex value sel retVal|
 
-	retVal := 0.
+        retVal := 0.
 
-	menuView args isNil ifTrue:[
-	    menuView selectors notNil ifTrue:[
+        menuView args isNil ifTrue:[
+            menuView selectors notNil ifTrue:[
 "/                sel := menuView selectors at:selected.
 "/                sel notNil ifTrue:[sel0 := sel].
 
 "/                (arg := menuView checkFlags at:selected) isNil ifTrue:[
-		    sel0 := menuView selectors at:selected.
+                    sel0 := menuView selectors at:selected.
 "/                ] ifFalse:[
 "/                    sel1 := menuView selectors at:selected.
 "/                ].
-		"/ retVal := nil.
-	    ]
-	] ifFalse:[
-	    actionIndex := menuView args at:selected.
-	    actionIndex notNil ifTrue:[
-		actionValues isNil ifTrue:[
-		    menuView selectors notNil ifTrue:[
-		    "/ mhmh an ST/X menu started the ST-80 way
-			sel1 := menuView selectors at:selected.
-			arg := actionIndex.
-			"/ retVal := nil.
-		    ] ifFalse:[
-			retVal := actionIndex
-		    ]
-		] ifFalse:[
-		    retVal := actionValues at:actionIndex.
-		    (retVal isKindOf:PopUpMenu) ifTrue:[
-			retVal := retVal startUp
-		    ]
-		]
-	    ] ifFalse:[
-		"/ mhmh an ST/X menu started the ST-80 way
-		menuView selectors notNil ifTrue:[
+                "/ retVal := nil.
+            ]
+        ] ifFalse:[
+            actionIndex := menuView args at:selected.
+            actionIndex notNil ifTrue:[
+                actionValues isNil ifTrue:[
+                    menuView selectors notNil ifTrue:[
+                    "/ mhmh an ST/X menu started the ST-80 way
+                        sel1 := menuView selectors at:selected.
+                        arg := actionIndex.
+                        "/ retVal := nil.
+                    ] ifFalse:[
+                        retVal := actionIndex
+                    ]
+                ] ifFalse:[
+                    retVal := actionValues at:actionIndex.
+                    (retVal isKindOf:PopUpMenu) ifTrue:[
+                        retVal := retVal startUp
+                    ]
+                ]
+            ] ifFalse:[
+                "/ mhmh an ST/X menu started the ST-80 way
+                menuView selectors notNil ifTrue:[
 "/                    (arg := menuView checkFlags at:selected) isNil ifTrue:[
-			sel0 := menuView selectors at:selected.
+                        sel0 := menuView selectors at:selected.
 "/                    ] ifFalse:[
 "/                        sel1 := menuView selectors at:selected.
 "/                    ].
-		    "/ retVal := nil.
-		]
-	    ]
-	].
-	return := retVal
+                    "/ retVal := nil.
+                ]
+            ]
+        ].
+        return := retVal
     ].
-    self showAtPointer.
+    aPoint isNil ifTrue:[
+        self showAtPointer
+    ] ifFalse:[
+        self showAt:aPoint.
+    ].
 
     "/ 
     "/ mhmh an ST/X menu started the ST-80 way
     "/
     (sel0 notNil or:[sel1 notNil]) ifTrue:[
-	rec := menuView receiver.
-	sel0 notNil ifTrue:[
+        rec := menuView receiver.
+        sel0 notNil ifTrue:[
 ^ sel0
 "/            rec perform:sel0
-	] ifFalse:[
+        ] ifFalse:[
 ^ Array with:sel1 with:arg.
 "/            rec perform:sel1 with:arg.
-	]
+        ]
     ].
     ^ return
 
     "
      Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')) startUp 
      Transcript showCr:(PopUpMenu labels:#('foo' 'bar' 'baz')
-				  values:#(foo bar baz)) startUp
+                                  values:#(foo bar baz)) startUp
     "
+
+    "Created: 10.1.1996 / 20:11:42 / cg"
+    "Modified: 10.1.1996 / 20:12:26 / cg"
 !
 
 startUpWithHeading:aString
@@ -924,5 +949,5 @@
 !PopUpMenu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.29 1995-12-15 13:04:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.30 1996-01-10 19:17:31 cg Exp $'
 ! !