REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: view

Description

The view function creates and updates windows. It takes a face as its argument. The contents of the window is determined from a face that holds a block of the graphical objects. The window face is normally created with the LAYOUT function, but faces can be constructed directly from face objects and displayed as well.

The example below opens a window and displays some text and a button.

view layout [
    h2 "The time is currently:"
    h3 form now
    button "Close" [unview]
]

The position and size of the window is determined from the face to be displayed. In the example above, the size of the window is automatically computed by the LAYOUT function. The window is shown in the default position in the upper left area of the screen.

The window's caption will be default be the title of the script that is being run. To provide a different caption, use the /title refinement and a string.

view/title layout [h1 "Window"] "A Window"

The first use of view within an application is special. It displays the window and initializes the graphical interface system. Subsequent calls to VIEW update the window, they do not create new windows unless the /new refinement is provided.

view layout [
    button "Change" [
        view layout [button "Stop" [unview]]
    ]
]

The first call to the VIEW function will not return immediately. At that point your code becomes event driven, calling the functions associated with various faces. While the first call to VIEW remains active, any other calls to VIEW will return immediately. The first call will return only after all windows have been closed.

Additionally, calls to view can specify options, such as whether the window has borders and is resizable. Single options are provided as a word and multiple options are specified in a block.

out: layout [vh1 "This is a window."]
view/options out [resize no-title]


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin