can now specify if menu action is to be performed by
authorca
Sat, 26 Oct 2002 17:46:27 +0200
changeset 1651 429e02e097d9
parent 1650 916067641a59
child 1652 e2a96fa70eef
can now specify if menu action is to be performed by originating widget (instead of application)
MenuItem.st
--- a/MenuItem.st	Fri Oct 25 20:27:20 2002 +0200
+++ b/MenuItem.st	Sat Oct 26 17:46:27 2002 +0200
@@ -19,7 +19,7 @@
 		triggerOnDown delayMenu indication submenu submenuChannel
 		shortcutKey labelImage accessCharacterPosition argument choice
 		choiceValue font auxValue showBusyCursorWhilePerforming
-		keepLinkedMenu horizontalLayout'
+		keepLinkedMenu horizontalLayout sendToOriginator'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Support'
@@ -464,6 +464,20 @@
 
 !
 
+sendToOriginator
+    "if true, the message is sent to the originating widget;
+     otherwise (the default), it it sent to the receiver/application."
+
+   ^ sendToOriginator ? false
+!
+
+sendToOriginator:anBoolean
+    "if true, the message is sent to the originating widget;
+     otherwise (the default), it it sent to the receiver/application."
+
+    sendToOriginator := anBoolean
+!
+
 translateLabel
     "returns whether label is translated
     "
@@ -614,118 +628,9 @@
     submenuChannel isNil ifTrue:[ coll add:#submenuChannel].
     self keepLinkedMenu ifFalse:[ coll add:#keepLinkedMenu].
     submenu value isNil ifTrue:[coll add:#submenu ].
+    self sendToOriginator ifFalse:[coll add:#sendToOriginator ].
 
     ^ coll
-!
-
-xxliteralArrayEncoding
-    "return myself encoded as a literal array"
-
-"/    |coll something|
-"/
-"/    coll := OrderedCollection new.
-"/    coll add:#MenuItem.
-"/
-"/    label notNil ifTrue:[
-"/        coll add:#label: ; add:(label literalArrayEncoding)
-"/    ].
-"/    self translateLabel ifTrue:[
-"/        coll add:#translateLabel: ; add:true
-"/    ].
-"/    self isButton ifTrue:[
-"/        coll add:#isButton:; add:true
-"/    ].
-"/
-"/    triggerOnDown == true ifTrue:[
-"/        coll add:#triggerOnDown: ; add:triggerOnDown
-"/    ].
-"/    hideMenuOnActivated == false ifTrue:[
-"/        coll add:#hideMenuOnActivated: ; add:hideMenuOnActivated
-"/    ].
-"/    nameKey notNil ifTrue:[
-"/        coll add:#nameKey: ; add:(nameKey literalArrayEncoding)
-"/    ].
-"/    isVisible notNil ifTrue:[
-"/        isVisible ~~ true ifTrue:[
-"/            coll add:#isVisible: ; add:(isVisible literalArrayEncoding)
-"/        ]
-"/    ].
-"/    (startGroup notNil and:[startGroup ~~ #left]) ifTrue:[
-"/        coll add:#startGroup: ; add:(startGroup literalArrayEncoding)
-"/    ].
-"/
-"/    value notNil ifTrue:[
-"/        coll add:#value: ; add:(value literalArrayEncoding).
-"/    ].
-"/    activeHelpKey notNil ifTrue:[
-"/        coll add:#activeHelpKey: ; add:(activeHelpKey literalArrayEncoding).
-"/    ].
-"/    (something := self enabled) notNil ifTrue:[
-"/        coll add:#enabled: ; add:(enabled literalArrayEncoding).
-"/    ].
-"/
-"/    (something := self shortcutKeyCharacter) notNil ifTrue:[
-"/        coll add:#shortcutKeyCharacter: ; add:(something literalArrayEncoding)
-"/    ].
-"/    (something := self font) notNil ifTrue:[
-"/        coll add:#font: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self accessCharacterPosition) notNil ifTrue:[
-"/        coll add:#accessCharacterPosition: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self horizontalLayout) == true ifTrue:[
-"/        coll add:#horizontalLayout: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self showBusyCursorWhilePerforming) == true ifTrue:[
-"/        coll add:#showBusyCursorWhilePerforming: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self argument) notNil ifTrue:[
-"/        "/ coll add:#argument: ; add:(something literalArrayEncoding)   -- cg: wrong - see decoder part.
-"/        something class == Array ifTrue:[
-"/            coll add:#argument: ; add:(something collect:[:each | each literalArrayEncoding]).
-"/        ] ifFalse:[
-"/            coll add:#argument: ; add:(something literalArrayEncoding)
-"/        ]
-"/    ].
-"/
-"/    (something := self resourceRetriever) notNil ifTrue:[
-"/        "/ ParcPlace stores the ResourceRetriever under the labelImage key.
-"/        coll add:#resourceRetriever: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self indication) notNil ifTrue:[
-"/        coll add:#indication: ; add:(something literalArrayEncoding)
-"/    ].
-"/    (something := self choice) notNil ifTrue:[
-"/        coll add:#choice: ; add:(something literalArrayEncoding).
-"/
-"/        (something := self choiceValue) notNil ifTrue:[
-"/            coll add:#choiceValue: ; add:(something literalArrayEncoding)
-"/        ].
-"/    ].
-"/    (something := self auxValue) notNil ifTrue:[
-"/        coll add:#auxValue: ; add:(something literalArrayEncoding)
-"/    ].
-"/
-"/    (something := self submenuChannel) notNil ifTrue:[
-"/        coll add:#submenuChannel: ; add:(something literalArrayEncoding).
-"/
-"/        (something := self keepLinkedMenu) ifTrue:[
-"/            coll add:#keepLinkedMenu: ; add:true
-"/        ]
-"/    ].
-"/
-"/    self hasSubmenu ifTrue:[
-"/        coll add:#submenu:; add:(self submenu literalArrayEncoding)
-"/    ].
-"/
-"/    ^ coll asArray
-"/
-"/    "Modified: / 14.8.1998 / 15:44:53 / cg"
 ! !
 
 !MenuItem methodsFor:'encoding & decoding'!
@@ -866,5 +771,5 @@
 !MenuItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.55 2002-10-25 11:14:44 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.56 2002-10-26 15:46:27 ca Exp $'
 ! !