[REBOL] Re: Accessing layout styles.
From: brett::codeconscious::com at: 10-Jul-2001 11:12
> How do you get at the styles in a layout without the use of variables?
When layout is finished you are left with an object that contains other
objects. These are face objects - they are no longer styles exactly. You can
traverse tree using the PANE field of the face. PANE can be none! or an
object! or a block!
my-layout: layout [title "the title" field "some text"]
print mold get in second my-layout/pane 'text
But this will not help you for what you want.
> I want to be able to open any number of new windows from a main
> window and have the new ones behave independently. Umm, this is what
> I mean...
> view layout [
> f: field "a"
> button "open" [
> view/new layout [
> t: text 100 copy f/text
> button "Change" [t/text: "changed!" show t]
> but the use of a variable there ('t) means the text in each new window
> is sharing the same variable and so only the most recent window
> opened can have its text changed. I need to get rid of that variable
> and get at the layout styles directly. I assume
Actually you probably don't need to get at the styles directly. What you
need is effectively a different variable for each new layout something
CONTEXT (object!) is good at. In the script below, when the button is
activated, an object is created with
two fields one contains the result of the LAYOUT function and the other a
reference to the TEXT. I add these objects
to a block. Therefore you can access them at a later time.
layout-contexts: copy 
view layout [
f: field "a"
button "open" [
lo-ctx: context [
t: none ; reserves a spot for t in the context
lo: layout [
t: text 100 copy f/text
button "Change" [t/text: "changed!" show t]
append layout-contexts lo-ctx
BTW, now you can do:
foreach ctx layout-contexts [print mold ctx/t]