Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] another question about contexts and layouts

From: mh983::yahoo::com at: 9-Mar-2002 13:19

I'm noticing come behavior that seems strange to me, and my brain hurts from thinking about it. Any help would be greatly appreciated. Does anybody have any idea why the following happens: I was playing around with a view/controller idea. The controller is just a context that I create an object from, and it knows about it's view. The view is a context that knows about it's controller and has a variable that contains it's layout definition. The problem I'm having is that if I create 2 controllers, the second controller seems to cause the first controller to point to the second ones view. I know this is confusing, so lets just get to the code. See embedded comments. REBOL [] controller-ctx: [ val: none myview: context view-ctx myview/mycontroller: self show-window: does [ val: 3 view layout myview/layout-ctx print myview/name ] ] view-ctx: [ mycontroller: none name: "unnamed" print-val: does [ print mycontroller/val ] layout-ctx: [ button "Print Value" [print ["the value: " mycontroller/val]] button "Print Name" [print ["view name: " name]] ] ] obj1: context controller-ctx obj1/myview/name: "view1" obj2: context controller-ctx obj2/myview/name: "view2" obj1/show-window ; NOTE: this is obj1 still, we're not using obj2. ; clicking on the Print Name button will print ; "view2" - so our controller, obj1, has ; the wrong view somehow, because of our ; creation of obj2. ; clicking the Print Value button will print "none", ; Since show-windows was never called for obj2, ; the value hasn't been set -- further evidence that ; obj1 has the wrong view object.