13 The controlactions Library

The controlactions library defines the actions related to the events, related to the interfaceObjects, described in the control library.

13.1 Using the controlactions Library

Remember that in order to utilize this extension to Lidskjalv, the fragment controlactions must be included as follows:

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/controlactions'
--- program: descriptor ---
guienv(# lca: @labelChangedAction;
         ...
      do ...
         lca[] -> appendAction;
         ...
      #)

13.2 Examples of Use of the controlactions Fragment

This example illustrates how to use the labelChangedAction to adjust the size of a pushButton to the length of its label.

Program 11: buttonactions.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/controls';
INCLUDE '~beta/guienv/controlsactions';
(* This demo shows how to use the labelChangedAction to adjust the
 * size of a pushButton to the length of its label.  The action is
 * created by remote access to show that actions can be added without
 * specializing the button.
 *)
--- program: descriptor ---
guienv
(# theWindow: @window
     (# theLabelChanged: @aButton.labelChangedAction
          (# theTextStyle: ^textStyle; widthOfLabel: @integer;
             lw,lh: @integer
          do aButton.size -> (lw,lh);
             aButton.style -> theTextStyle[];
             aButton.label -> theTextStyle.widthOfText -> widthOfLabel;
             (if (lw < widthOfLabel + 6) then
                 widthOfLabel + 6 -> lw
             if);
             (if (lh < theTextStyle.lineHeight + 2) then
                 theTextStyle.lineHeight + 2 -> lh
             if);
             (lw,lh) -> aButton.size
          #);
        aButton: @pushButton;
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        open::
          (# 
          do (40,40) -> position;
             (300,300) -> size;
             aButton.open;
             (10,10) -> aButton.position; 
             (50,16) -> aButton.size;
             'Button1' -> aButton.label;
             theLabelChanged[] -> aButton.appendAction;
             'A Long Button Label' -> aButton.label
          #)
     #)
do theWindow.open
#)
[23kb 295x311 GIF]


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