Alternative name: Static
The Label (or Static) class implements simple text labels.
Normally you need to set only the caption property, which determines the text displayed, and the where property, to determine where it is placed on the window. You can also set the font, color and enabled properties for special effects (if enabled is 0, the text is grayed out).
Under Windows and Linux only. the style property for a static text object sets the text alignment:
0 = Left justified 1 = Centered 2 = Right justified plus optional bits: 4 = Inhibit prefix (interpretation of '&' as accelerator key (Windows, Linux only) 8 = Inhibit word-wrap if the text is too wide for the label 32 = Inhibit auto-sizing of the label to ensure text fits 128 = Text is transparent (Windows, Linux only)
Event handling is not usually relevant to Label objects, but sometimes it is useful to define an onMouseDown callback. In this case, you should usually provide some visual indication to the user that the text is capable of responding to mouse events, for example by displaying it in a special color or underlining it using the font property. This can be used for 'hypertext' type applications where the user clicks on a word for more information about it.
Note: Another way of displaying text on a window or control is to use the Draw method. This provides more flexibility in specifying the font colors and transparency, and also allows you to write text at any angle. Under Windows, it is also useful where you want the text to appear over another control; Label objects always display behind windowed controls such as Buttons.
∇DEMO_Label;DEMO  ⍝ Sample function demonstrating use of the Label object  DEMO←'⎕' ⎕NEW 'Window' ⋄ DEMO.scale←1  DEMO.title←'Label Example'  ⍝  DEMO.LABEL1.New 'Label'  DEMO.LABEL1.caption←'Today''s Work Plan'  DEMO.LABEL1.where←2 1 1 30  DEMO.LABEL1.font←'Helvetica' 1 1 ⍝ Bold text  ⍝  DEMO.LABEL2.New 'Label'  DEMO.LABEL2.caption←'Tidy up the office!'  DEMO.LABEL2.where←4 1 1 30  DEMO.LABEL2.enabled←0  ⍝  DEMO.LABEL3.New 'Label'  DEMO.LABEL3.caption←'Have lunch'  DEMO.LABEL3.where←6 1 1 30  DEMO.LABEL3.font←'Helvetica' 1 0  DEMO.LABEL3.color←255  ⍝  ⍝ Wait for the user to close the window  0 0⍴⎕WE DEMO ∇
align anchors aquaadjust autodraw caption children class color data dragsource droptarget enabled events extent font maxsize methods minsize name opened pointer properties scale self size sourceformats style targetformats tie tooltip units visible where
Copyright © 1996-2010 MicroAPL Ltd