when accepting, and the application does not respond to that
authorClaus Gittinger <cg@exept.de>
Sat, 05 Feb 2000 14:42:44 +0100
changeset 1679 af40842718f6
parent 1678 db691e5dba83
child 1680 f4214f754c57
when accepting, and the application does not respond to that menu message, try to send it to the masterApplication (if present). Useful for subcanvases. Q: should we try them the othr way round ?
MenuPanel.st
--- a/MenuPanel.st	Fri Feb 04 16:42:53 2000 +0100
+++ b/MenuPanel.st	Sat Feb 05 14:42:44 2000 +0100
@@ -572,76 +572,92 @@
 accept:anItem index:anIndex toggle:aState receiver:aReceiver
     "accept an item
     "
-    |value argument numArgs isKindOfValueModel rec arg2 app|
+    |value argument numArgs isKindOfValueModel rec args arg2 
+     app master|
 
     anItem isNil ifTrue:[
-	self menuAdornmentAt:#hasPerformed put:true.
+        self menuAdornmentAt:#hasPerformed put:true.
       ^ nil
     ].
 
     self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel).
 
     (value := anItem value) isNil ifTrue:[
-	^ anIndex
+        ^ anIndex
     ].
 
     (argument := anItem argument) isNil ifTrue:[
-	argument := aState ? anItem
+        argument := aState ? anItem
     ].
 
     value isSymbol ifFalse:[
-	numArgs := value perform:#numArgs ifNotUnderstood:0.
-
-	numArgs == 0 ifTrue:[
-	    value value
-	] ifFalse:[
-	    numArgs == 1 ifTrue:[
-		value value:argument]
-	    ifFalse:[
-		value value:argument value:self
-	    ]
-	].
-	self menuAdornmentAt:#hasPerformed put:true.
+        "/ a valueHolder or block
+
+        numArgs := value perform:#numArgs ifNotUnderstood:0.
+
+        numArgs == 0 ifTrue:[
+            value value
+        ] ifFalse:[
+            numArgs == 1 ifTrue:[
+                value value:argument]
+            ifFalse:[
+                value value:argument value:self
+            ]
+        ].
+        self menuAdornmentAt:#hasPerformed put:true.
       ^ anIndex
     ].
 
     aReceiver isNil ifTrue:[
-	^ value
+        ^ value
     ].
 
     isKindOfValueModel := aReceiver isValueModel.
     isKindOfValueModel ifTrue:[
-	aReceiver value:value
+        aReceiver value:value
     ] ifFalse:[
-	rec := aReceiver.
-	arg2 := self.
-
-	"/ support for ST80 style applications
-	"/ (expecting the message to go to the application
-	"/  if not understood by the view)
-	"/ These expect the controller to be passed as argument.
-	"/ sigh.
-
-	(aReceiver isView
-	and:[(aReceiver respondsTo:value) not
-	and:[(app := aReceiver application) ~~ aReceiver
-	and:[app notNil]]]) ifTrue:[
-	    rec := app.
-	    arg2 := aReceiver controller "/ the Views controller
-	].
-
-	(numArgs := value numArgs) == 0 ifTrue:[
-	    rec perform:value
-	] ifFalse:[
-	    numArgs == 1 ifTrue:[
-		rec perform:value with:argument
-	    ] ifFalse:[
-		rec perform:value with:argument with:arg2
-	    ]
-	]
+        rec := aReceiver.
+        arg2 := self.
+
+        "/ support for ST80 style applications
+        "/ (expecting the message to go to the application
+        "/  if not understood by the view)
+        "/ These expect the controller to be passed as argument.
+        "/ sigh.
+
+        (aReceiver isView
+        and:[(aReceiver respondsTo:value) not
+        and:[(app := aReceiver application) ~~ aReceiver
+        and:[app notNil]]]) ifTrue:[
+            rec := app.
+            arg2 := aReceiver controller "/ the Views controller
+        ].
+
+        (numArgs := value numArgs) == 0 ifTrue:[
+            args := nil
+        ] ifFalse:[
+            numArgs == 1 ifTrue:[
+                args := Array with:argument
+            ] ifFalse:[
+                args := Array with:argument with:arg2
+            ]
+        ].
+
+        rec perform:value withArguments:args ifNotUnderstood:[
+            "/ mhmh - the receiver did not respond to that message;
+            "/ if there is a master-application, try that one
+            master := rec perform:#masterApplication ifNotUnderstood:nil.
+            master notNil ifTrue:[
+                master perform:value withArguments:args
+            ] ifFalse:[
+                self error:'unimplemented menu message:' , value
+            ].
+        ].
     ].
     self menuAdornmentAt:#hasPerformed put:true.
     ^ value
+
+    "Modified: / 4.2.2000 / 19:19:41 / cg"
 !
 
 acceptItem:anItem inMenu:aMenu
@@ -884,7 +900,7 @@
     self onEachPerform:#value: withArgList:something
 ! !
 
-!MenuPanel methodsFor:'accessing behavior'!
+!MenuPanel methodsFor:'accessing-behavior'!
 
 disableAll
     "disable all items; not the menu in case of enabled
@@ -953,7 +969,7 @@
     ^ self enabledAt:stringOrNumber
 ! !
 
-!MenuPanel methodsFor:'accessing channels'!
+!MenuPanel methodsFor:'accessing-channels'!
 
 enableChannel
     "gets a enable channel or nil
@@ -993,7 +1009,7 @@
     self menu:(menuHolder value)
 ! !
 
-!MenuPanel methodsFor:'accessing color & font'!
+!MenuPanel methodsFor:'accessing-color & font'!
 
 activeBackgroundColor
     "get the background drawing color used to highlight selection
@@ -1226,7 +1242,7 @@
     "Modified: / 6.6.1998 / 19:50:32 / cg"
 ! !
 
-!MenuPanel methodsFor:'accessing dimensions'!
+!MenuPanel methodsFor:'accessing-dimensions'!
 
 height
     "default height
@@ -1330,7 +1346,7 @@
     ^ RightArrowForm width
 ! !
 
-!MenuPanel methodsFor:'accessing items'!
+!MenuPanel methodsFor:'accessing-items'!
 
 itemAt:stringOrNumber
     "returns item assigned to an index, nameKey, textLabel or value if symbol.
@@ -1368,7 +1384,7 @@
     ^ items notNil ifTrue:[items at:anIndex ifAbsent:nil] ifFalse:[nil]
 ! !
 
-!MenuPanel methodsFor:'accessing look'!
+!MenuPanel methodsFor:'accessing-look'!
 
 buttonActiveLevel
     "get the button active level
@@ -1492,7 +1508,7 @@
     ]
 ! !
 
-!MenuPanel methodsFor:'accessing submenu'!
+!MenuPanel methodsFor:'accessing-submenu'!
 
 subMenuAt:stringOrNumber
     "gets the submenu of an item or nil
@@ -3675,9 +3691,11 @@
 argument:anArgument
     "sets the argument
     "
-    self argument ~~ anArgument ifTrue:[
-	self adornment argument:anArgument.
+    (anArgument notNil or:[adornment notNil]) ifTrue:[
+        self adornment argument:anArgument.
     ]
+
+    "Modified: / 4.2.2000 / 12:41:00 / cg"
 !
 
 basicGetSubmenu
@@ -3851,7 +3869,7 @@
     self argument:anArgument.
 ! !
 
-!MenuPanel::Item methodsFor:'accessing behavior'!
+!MenuPanel::Item methodsFor:'accessing-behavior'!
 
 choice
     "get choice indication
@@ -3903,10 +3921,13 @@
 choiceValue:something
     "set choice value
     "
-    self adornment choiceValue:something.
-    self updateRawLabel.
+    (something notNil or:[adornment notNil]) ifTrue:[
+        self adornment choiceValue:something.
+        self updateRawLabel.
+    ]
 
     "Created: / 14.8.1998 / 15:46:59 / cg"
+    "Modified: / 4.2.2000 / 12:41:45 / cg"
 !
 
 enabled
@@ -4042,7 +4063,7 @@
     submenuChannel := aSelectorOrNil.
 ! !
 
-!MenuPanel::Item methodsFor:'accessing dimension'!
+!MenuPanel::Item methodsFor:'accessing-dimension'!
 
 height
     "gets height
@@ -4088,7 +4109,7 @@
     ^ layout width
 ! !
 
-!MenuPanel::Item methodsFor:'accessing help'!
+!MenuPanel::Item methodsFor:'accessing-help'!
 
 activeHelpKey
     "get the active helpKey; the key to retrieve the helpText from the application
@@ -5551,6 +5572,6 @@
 !MenuPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.188 2000-02-02 14:44:44 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.189 2000-02-05 13:42:44 cg Exp $'
 ! !
 MenuPanel initialize!