Accessing layout styles.
[1/6] from: carl:cybercraft at: 10-Jul-2001 12:34
How do you get at the styles in a layout without the use of variables?
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
system/view/somthing-or-other is what I need, I just don't know what
the path is for the active window.
Any help appreciated.
--
Carl Read
[carl--cybercraft--co--nz]
[2/6] from: brett::codeconscious::com at: 10-Jul-2001 11:12
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
<<quoted lines omitted: 12>>
> 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
[3/6] 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?
<<quoted lines omitted: 12>>
> > I mean...
> >
my-window!: context[
f: t: none
view-me: does[
> > view layout [
> > f: field "a"
<<quoted lines omitted: 5>>
> > ]
> > ]
]
]
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
<<quoted lines omitted: 27>>
> HTH!
> Brett
-Volker
[4/6] from: agem:crosswinds at: 10-Jul-2001 4:21
RE: [REBOL] Re: Accessing layout styles.
seems i need the coffee.
i wanted to reply to the original mail
without observing now it was yours.
sorry Brett.. :-|
-Volker
[agem--crosswinds--net] wrote:
[5/6] from: brett:codeconscious at: 10-Jul-2001 12:39
> seems i need the coffee.
>
> i wanted to reply to the original mail
> without observing now it was yours.
First I was confused then I learnt how you set up your contexts - so it was
different and useful :)
> sorry Brett.. :-|
No Prob.
Brett.
[6/6] from: carl:cybercraft at: 10-Jul-2001 19:02
Many thanks, Brett and Volker. 'context is obviously what I wanted.
Using Volker's approach (because it seemed the simpliest) and
seperating the new windows from the main window, this is what I came
up with and it works a treat...
window-template!: context [
t: none
open-window: does [
view/new layout [
t: text f/text 100
button "Change" [t/text: "Changed!" show t]
]
]
]
view layout [
f: field "a"
button "open" [make window-template! [open-window]]
]
--
Carl Read
[carl--cybercraft--co--nz]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted