3.5 Examples of Use of the guienv Fragment

The demo programs in this manual can be found in the reference demo subdirectory in the guienv directory. The location of the directory in installation-dependent

~beta/guienv/demo/ReferenceDemos

The demo directory contains many more demo programs than is included in this manual. Please inspect the demo directory for other illustrative demo programs. Appendix A contains a short overview of the demos in the demo directory.

This demo program is nearly the simplest possible Lidskjalv program. It opens one window and prints activate (resp. deactivate) each time the window is made active (resp. inactive).

Program 1: simplewindow.bet

ORIGIN '~beta/guienv/guienv';
(* This demo shows how to create a very simple window and it
 * illustrates the activate/deactivate event.
 *)
--- program: descriptor ---
guienv
(# simpleWindow: @window
     (# eventHandler::
          (# onAboutToClose:: (# do terminate #);
             onActivate::
               (# do 'activate' -> putline #);
             onDeactivate::
               (# do 'deactivate' -> putline #)
          #);
        open:: 
          (# do (400,400) -> size #)
     #)
do simpleWindow.open
#)

[28kb 459x279 GIF]

This demo program illustrates the use of standard menubar where the file menu only has one menuItem. It also illustrates how to further bind noMouseUp, onMouseDown and onKeyDown event patterns.

Program 2: windowWithStdMenubar.bet

ORIGIN '~beta/guienv/guienv';
(* This demo shows how to create a simple window with a
 * standardMenubar where the file menu only has one menuitem. It also
 * illustrates how to further bind the onMouseDown, onMouseUp,
 * onKeyDown event patterns.
 *)
--- program: descriptor ---
guienv
(# theWindow: @window
     (# menubarType:: standardMenubar
          (# fileMenu::
               (# quitItem: @menuitem
                    (# open::
                         (# do 'Quit' -> name #);
                      eventHandler::
                         (# onSelect::
                              (# do terminate #)
                         #)
                    #);
                  open::
                    (# 
                    do 'File' -> name;
                       quitItem.open; quitItem[] -> append
                    #)
               #)
          #);
        eventHandler::
          (# onAboutToClose:: (# do terminate #);
             onMouseDown::
               (# 
               do 'MouseDown: ' -> puttext;
                  buttonState -> putint;
                  (if doubleClick then
                      ' doubleclick' -> puttext
                  if);
                  newLine
               #);
             onMouseUp::
               (# 
               do 'onMouseUp ' -> puttext;
                  buttonState -> putint;
                  (if doubleClick then
                      ' doubleclick' -> puttext
                  if);
                  newLine
               #);
             onKeyDown::
               (# 
               do 'onKeyDown: ' -> puttext;
                  ch -> put;
                  newLine
               #)
          #)
     #)
do theWindow.open
#)

[7kb 312x229 GIF]


Lidskjalv: User Interface Framework - Reference Manual
© 1994-2002 Mjølner Informatics
[Modified: Friday January 4th 2002 at 13:10]