View.st
changeset 1147 83ed804938e7
parent 1146 0167191529dd
child 1149 a3a75ffb29ce
--- a/View.st	Mon Dec 23 13:45:37 1996 +0100
+++ b/View.st	Mon Dec 23 13:59:08 1996 +0100
@@ -181,18 +181,88 @@
 
 menuHolder
     "who has the menu ? 
-     By default, its the model if I have one."
+     If no explicit menuHolder was defined, its the model if I have one.
+     Otherwise, its the menuHolder (if nonNil) or mySelf.
+     The menuHolder is supposed to return a popUpMenu when asked via the
+     menuMessage."
 
+    menuHolder notNil ifTrue:[^ menuHolder].
     model notNil ifTrue:[^ model].
     ^ self
+
+    "Modified: 23.12.1996 / 13:56:55 / cg"
+!
+
+menuHolder:anObject
+    "change the one that provides the menu (via menuMsg)."
+
+    menuHolder := anObject
+
+    "Created: 23.12.1996 / 13:54:33 / cg"
+!
+
+menuMessage
+    "Return the symbol sent to the model to aquire the menu"
+
+    ^ menuMsg
+!
+
+menuMessage:aSymbol
+    "ST-80 style menus: If a views menuSymbol is nonNil, it
+     will send it to its model when the middleButton is pressed.
+     That method should return nil or the menu to be shown.
+     This is useful for very dynamic menus, where it does not
+     make sense to define an initial menu.
+     This is the same as #menu: which was added for ST-80 compatibility."
+
+    menuMsg := aSymbol
 !
 
 menuPerformer
     "who should perform the menu actions ? 
-     By default, its the model if I have one."
+     If no menuPerformer was defined, its the model if I have one.
+     Otherwise its the menuPerformer (if nonNil), or myself.
+     The menuPerformer get messages from the menu"
 
+    menuPerformer notNil ifTrue:[^ menuPerformer].
     model notNil ifTrue:[^ model].
     ^ self
+
+    "Modified: 23.12.1996 / 13:57:18 / cg"
+!
+
+menuPerformer:anObject
+    "change the one that does the menu actions.
+     See the comment in SimpleView>>activateMenu on who gets the menus
+     message."
+
+    menuPerformer := anObject
+
+    "
+     |top textV plug|
+
+     plug := Plug new.
+     plug respondTo:#textMenu
+               with:[ |m|
+                        m := PopUpMenu
+                                  labels:#('copy' 'foo' '-' 'others')
+                                  selectors:#(copySelection foo nil others).
+                        m subMenuAt:#others
+                                put:(PopUpMenu 
+                                        labels:#('bar' 'goto')
+                                        selectors:#(bar gotoLine))        
+                    ].
+
+     top := StandardSystemView new.
+     top extent:300@300.
+
+     textV := TextView origin:0.0@0.0 corner:1.0@1.0 in:top.
+     textV menuHolder:plug; menuMessage:#textMenu; menuPerformer:plug.
+     textV contents:'hello world'.
+     top open.
+    "
+
+    "Created: 23.12.1996 / 13:57:28 / cg"
 ! !
 
 !View methodsFor:'accessing-mvc'!
@@ -271,23 +341,6 @@
     menuMsg := menuSymbol
 !
 
-menuMessage
-    "Return the symbol sent to the model to aquire the menu"
-
-    ^ menuMsg
-!
-
-menuMessage:aSymbol
-    "ST-80 style menus: If a views menuSymbol is nonNil, it
-     will send it to its model when the middleButton is pressed.
-     That method should return nil or the menu to be shown.
-     This is useful for very dynamic menus, where it does not
-     make sense to define an initial menu.
-     This is the same as #menu: which was added for ST-80 compatibility."
-
-    menuMsg := aSymbol
-!
-
 model
     "return the model, for non-MVC views,
      this is nil or the receiver"
@@ -484,5 +537,5 @@
 !View class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.52 1996-12-23 12:45:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.53 1996-12-23 12:59:08 cg Exp $'
 ! !