[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.
myview: context view-ctx
show-window: does [
view layout myview/layout-ctx
print-val: does [
button "Print Value" [print ["the value: "
button "Print Name" [print ["view name: " name]]
obj1: context controller-ctx
obj2: context controller-ctx
; 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.