fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
authorClaus Gittinger <cg@exept.de>
Thu, 07 Mar 1996 19:49:31 +0100
changeset 495 d993f23ea658
parent 494 ce6292172214
child 496 f22ac16a5093
fixed subMenus with a menuPerformer (now also behaves the ST-80 way)
MenuView.st
PopUpMenu.st
--- a/MenuView.st	Thu Mar 07 19:46:39 1996 +0100
+++ b/MenuView.st	Thu Mar 07 19:49:31 1996 +0100
@@ -1535,9 +1535,12 @@
 initEvents
     super initEvents.
     self enableLeaveEvents.
+
     windowGroup notNil ifTrue:[
-	windowGroup sensor compressMotionEvents:true
+        windowGroup sensor compressMotionEvents:true
     ]
+
+    "Modified: 7.3.1996 / 14:18:09 / cg"
 !
 
 initStyle
@@ -1781,7 +1784,11 @@
                     AbortSignal handle:[:ex |
                         ex return
                     ] do:[
-                        actionBlock value:selection
+                        actionBlock numArgs == 1 ifTrue:[
+                            actionBlock value:selection
+                        ] ifFalse:[
+                            actionBlock value:self value:selection
+                        ]
                     ]
                 ] ifFalse:[
                     selectors notNil ifTrue: [
@@ -1826,7 +1833,7 @@
     ]
 
     "Created: 4.3.1996 / 11:19:22 / cg"
-    "Modified: 5.3.1996 / 14:47:56 / cg"
+    "Modified: 7.3.1996 / 18:59:59 / cg"
 !
 
 recomputeSize
@@ -1929,26 +1936,35 @@
      to map the subview there
     "
     org := device 
-		translatePoint:(mx @ my) 
-		from:(self id) 
-		to:(device rootWindowId).
-
-"/ mhmh - is this still needed ?
+                translatePoint:(mx @ my) 
+                from:(self id) 
+                to:(device rootWindowId).
+
     "
      before showing, process all of my expose events
     "
+    "/ mhmh - is this still needed ?
     windowGroup notNil ifTrue:[
-	windowGroup processExposeEvents
+        windowGroup processExposeEvents
     ].
 
     m superMenu:self.
 
+    actionBlock notNil ifTrue:[
+        "/ mhmh - I am an ST-80 style menu
+        "/ which does not send any messages to the receiver,
+        "/ but returns the selector instead.
+        "/ let my submenu do so as well ...
+
+         m menuView action:actionBlock
+    ].
+
     "
      realize the submenu in MY windowgroup
     "
     windowGroup notNil ifTrue:[
-	m windowGroup:windowGroup.
-	windowGroup addTopView:m.
+        m windowGroup:windowGroup.
+        windowGroup addTopView:m.
     ].
     m fixSize.
     m origin:org.
@@ -1958,6 +1974,8 @@
     device flush.
 
     subMenuShown := m
+
+    "Modified: 7.3.1996 / 18:23:59 / cg"
 ! !
 
 !MenuView methodsFor:'queries'!
@@ -2360,5 +2378,5 @@
 !MenuView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.60 1996-03-07 12:57:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.61 1996-03-07 18:49:04 cg Exp $'
 ! !
--- a/PopUpMenu.st	Thu Mar 07 19:46:39 1996 +0100
+++ b/PopUpMenu.st	Thu Mar 07 19:49:31 1996 +0100
@@ -580,32 +580,36 @@
 
     return := 0.
 
-    menuView action:[:selected |
-        |actionIndex value sel retVal|
+    "/
+    "/ arrange for the menu to evaluate this action,
+    "/ instead of directly sending any messages to the menuReceiver.
+    "/ (which used to be the ST/X way, menus worked).
+    "/ This works better with menuPerformers - which were not
+    "/ supported when ST/X menus were originally written.
+    "/ The old ST/X mechanism may vanish.
+    "/
+
+    menuView action:[:menuView :selected |
+        |actionIndex value sel retVal args selectors|
 
         retVal := 0.
 
-        menuView args isNil ifTrue:[
-            menuView selectors notNil ifTrue:[
-"/                sel := menuView selectors at:selected.
-"/                sel notNil ifTrue:[sel0 := sel].
+        args := menuView args.
+        selectors := menuView selectors.
 
-"/                (arg := menuView checkFlags at:selected) isNil ifTrue:[
-                    sel0 := menuView selectors at:selected.
-"/                ] ifFalse:[
-"/                    sel1 := menuView selectors at:selected.
-"/                ].
-                "/ retVal := nil.
+        args isNil ifTrue:[
+            selectors notNil ifTrue:[
+                sel0 := selectors at:selected.
             ]
         ] ifFalse:[
-            actionIndex := menuView args at:selected.
+            actionIndex := 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.
+                    selectors notNil ifTrue:[
+                        "/ mhmh an ST/X menu started the ST-80 way
+
+                        sel1 := selectors at:selected.
                         arg := actionIndex.
-                        "/ retVal := nil.
                     ] ifFalse:[
                         retVal := actionIndex
                     ]
@@ -617,18 +621,15 @@
                 ]
             ] 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.
-"/                    ] ifFalse:[
-"/                        sel1 := menuView selectors at:selected.
-"/                    ].
-                    "/ retVal := nil.
+
+                selectors notNil ifTrue:[
+                    sel0 := selectors at:selected.
                 ]
             ]
         ].
         return := retVal
     ].
+
     aPoint isNil ifTrue:[
         self showAtPointer
     ] ifFalse:[
@@ -641,12 +642,9 @@
     (sel0 notNil or:[sel1 notNil]) ifTrue:[
         rec := menuView receiver.
         sel0 notNil ifTrue:[
-^ sel0
-"/            rec perform:sel0
-        ] ifFalse:[
-^ Array with:sel1 with:arg.
-"/            rec perform:sel1 with:arg.
-        ]
+            ^ sel0
+        ].
+        ^ Array with:sel1 with:arg.
     ].
     ^ return
 
@@ -657,7 +655,7 @@
     "
 
     "Created: 10.1.1996 / 20:11:42 / cg"
-    "Modified: 4.3.1996 / 22:14:47 / cg"
+    "Modified: 7.3.1996 / 18:23:26 / cg"
 !
 
 startUpWithHeading:aString
@@ -999,7 +997,9 @@
 initEvents
     super initEvents.
     self enableEnterLeaveEvents.
-    self enableMotionEvents.
+"/    self enableMotionEvents.
+
+    "Modified: 7.3.1996 / 14:17:42 / cg"
 !
 
 initialize
@@ -1071,5 +1071,5 @@
 !PopUpMenu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.41 1996-03-07 12:56:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.42 1996-03-07 18:49:31 cg Exp $'
 ! !