8.2 Interactive Graphics Facilities

Interactive graphics in window is handled through the definition of event handlers of the windowItems attached with the window. The actual event handling of the window items (realizing that they are clicked, the mouse is entering them, etc) is handled entirely by Lidskjalv. The refresh of window items are also handled entirely by Lidskjalv. Please note, that these interactive facilities applies for all subpatterns of windowItem (i.e. not only for subpatterns of figureItem). Figure items are merely used here for demonstrative purposes.

8.2.1 Selection of Graphics Objects

Selection of a windowItem is realized by specializing the onMouseDown event pattern in the appropriate windowItem. E.g.

Program 13: ovalSelect.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/figureitems'
--- program: descriptor ---
guienv
(# selectWindow: @window
     (# go: @oval
          (# open::
               (# 
               do (100, 100)->position;
                  (50, 100)->size;
               #);
             eventhandler::
               (# onMouseDown:: (# do 'Selected...'->puttext #) #)
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        open::
          (# 
          do (100, 100)->position;
             (300, 300)->size;
             'ovalSelect'->title;
             go.open
          #)
     #)
do selectWindow.open
#)

Program 14: screendumps
(Windows 95)

[3kb 116x114 GIF] [7kb 135x152 GIF]

8.2.2 Dragging of Graphics Objects

Dragging is specified using the drag pattern of windowItem. Dragging of e.g. a oval can specified as follows:

Program 15: ovalDrag.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/figureitems'
--- program: descriptor ---
guienv
(# dragWindow: @window
     (# go: @oval 
          (# open::
               (# 
               do (100, 100)->position;
                  (50, 100)->size;
                  7->pen.size
               #);
             eventhandler:: 
               (# onMouseDown:: (# do drag #) #)
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        open:: 
          (# 
          do (100, 100)->position;
             (300, 300)->size;
             'ovalDrag'->title;
             go.open
          #)
     #)
do dragWindow.open
#)


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