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

[REBOL] Re: Accessing layout styles.

From: agem:crosswinds at: 10-Jul-2001 3:37

RE: [REBOL] Re: Accessing layout styles. [brett--codeconscious--com] wrote:
> Hi Carl, > > > 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! > > For example: > > my-layout: layout [title "the title" field "some text"] > type? my-layout/pane > length? my-layout/pane > 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... > >
my-window!: context[ f: t: none view-me: does[
> > view layout [ > > f: field "a" > > button "open" [ > > view/new layout [ > > t: text 100 copy f/text > > button "Change" [t/text: "changed!" show t] > > ] > > ] > > ]
] ] make my-window! [view-me] and each has its own 'f and '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 > view/new lo-ctx/lo > ] > ] > > BTW, now you can do: > > foreach ctx layout-contexts [print mold ctx/t] > > HTH! > Brett >
-Volker