7 The Menu Bar

The menuBar attribute of Guienv is the interface to the underlying window system menubar. menuBar.Clear removes all menus from the menubar. If theMenu is a menu (discussed earlier), theMenu[]->menuBar.append inserts theMenu as the last menu in the menubar and menus are removed from the menubar by theMenu[]->menuBar.delete.

7.1 Standard Menus

Most window systems have user interface guidelines that defines that the two first menus of any applications must be: File and Edit. It is also often the case that the File menu contains at least New, Open, Close, Save, Save As, Revert, Print, , Page Setup and Quit, and that the Edit menu contains at least Undo, Cut, Copy, Paste and Clear.

To make it easy to create such menus, Lidskjalv contains a pattern standardMenuBar, containing two menu definitions: standardFileMenu and standardEditMenu, with exactly those menu item described above (as dynamic meny items).

These menu items are realized by instances of dynamicMenuItem with related names (e.g. saveMenuItem for the Save item). The actions to be associated with the individual items are specified by attaching an menuAction to the menu item in question, e.g.

anMenuAction[]->theFileMenu.saveMenuItem.attach

E.g.:

Program 9: fileMenu.bet

ORIGIN '~beta/guienv/guienv'
--- program: descriptor ---
guienv
(# fileMenuWindow: @window
     (# menubarType:: standardMenubar
          (# fileMenu:: standardFileMenu
               (# newMenuAction: @menuAction
                    (# onSelect:: (# do 'New...'->putline #) #);
                  saveMenuAction: @menuAction
                    (# onSelect:: (# do 'Saving...'->putline #) #);
                  saveAsMenuAction: @menuAction
                    (# onSelect:: (# do 'Saving As...'->putline #) #);
                  open::
                    (#
                    do newMenuAction[]->newMenuItem.attach;
                       saveMenuAction[]->saveMenuItem.attach;
                       saveAsMenuAction[]->saveAsMenuItem.attach
                    #)
               #);
             editMenu:: standardEditMenu
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        open:: (# do 'fileMenu'->title #)
     #)
do fileMenuWindow.open
#)

Note that the open attribute, further bound in fileMenu is automatically invoked on the theFileMenu instance during the initialization of Guienv.

Program 10: Screendumps(Windows 95)

[7kb 140x176 GIF]   [7kb 135x152 GIF]


Lidskjalv: User Interface Framework - Tutorial
© 1995-2002 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]