[REBOL] Re: First attempt at Rebol - 16 hours later
From: carl:cybercraft at: 30-Sep-2007 13:20
On Wednesday, 26-September-2007 at 18:53:56 greg.schofield wrote,
>Anton, I did not want you to think I am rude.
>
>I am still trying to get my head around Layout activation, I am missing s
>omething simple and obvious. I can display the GUI, but not make them wo
>rk.
Hi Greg,
By 'not making them work', what do you mean? (I tried Anton's example and while I couldn't
get it to run by cutting and pasting it into the console, (even after I'd tidied up the
wrapped lines), it did run after I'd turned it into a script. Not that I knew what to
do with it then - but it was alive.)
My general approach to layouts is to have a main layout from which other layouts can
be opened (if required) using view/new.
An example...
;-- Layouts...
main-lo: layout [
text-box: area 400x200
across
btn "Add Random Line" [add-line]
btn "Open Second Window" [view/new second-lo]
btn "Does nothing"
btn "Does nothing too" [] ; Needs stuff in the block to do anything.
return
btn "Close all Windows" [unview/all]
]
second-lo: layout [
banner "Hello REBOLs!!!" black
btn "Close Me!" [unview/only second-lo]
]
;-- A function.
add-line: func [
"Add a line of characters to the text in text-box and display it."
][
loop random 6 [append text-box/text random " qwertyuiop"]
append text-box/text "^/" ; Add return character.
show text-box
]
;-- Open main layout...
view main-lo
Note with this approach only one version of the second window can be opened at once,
which is what you mostly want.
View docs I'm afraid are all over the place. The official REBOL/Core guide (in book
form and online) is very good, but there's never been a decent (or any?) book in English
released for View, though Olivier Auverlot's French one is supposed to be very good.
Hopefully it'll all be rectified when R3 leaves beta.
Anyway, hope the above helps and don't be afraid to ask any questions here. It's what
the list is for and REBOL sure needs more newbies!
-- Carl Read.