Where the user is expected to enter text, you typically use an Edit object. Depending on the style property, this can be single- or multi-line, and can optionally be read-only.
The text in an Edit object is all displayed in the same font, size, style and color. (If you want to allow multiple fonts, styles, sizes and colors, use the RichEdit control instead).
At any time, the text property contains the displayed text; it can be set either under program control (for example, to set up an initial default) or by the user typing. In addition, the selection property allows you to get or set the position of the cursor and the text selection position. If you want to restrict the maximum number of characters entered, use the limit property.
You can set the font, color and enabled properties for special effects. The border property for Edit texts defaults to 1, which means that a border is drawn. If you do not want this, set it to 0.
The style property for an edit control is the sum of a set of flags:
1 = Centered 2 = Right justified 4 = Multiline 16 = Vertical scroll bar 32 = Inhibit auto horizontal scroll (i.e. word wrap if multiline) 64 = Horizontal scroll bar 1024 = Show selection even when control does not have focus (Windows only) 4096 = Read only 8192 = Allow Enter chars (multi-line only) 131072 = Allow Tab characters to be input, instead of tabbing to next control 262144 = Disable unnecessary scroll bars instead of removing them (MacOS only)
To provide help text when the user moves the mouse pointer over the control and pauses, you can use the tooltip property.
The Cut, Copy and Paste methods can be used to cut and paste to and from the clipboard.
There are several callbacks which are often used for Edit text objects. These include:
onClick: Invoked when the cursor position or text selection is changed
onChange: Invoked when the text is modified
onFocus: The Edit text object has got input focus
onUnfocus: The object has lost focus (often used to validate user input)
onLimit: The user has attempted to enter more characters than allowed by the limit property
∇DEMO_Edit;DEMO  ⍝ Sample function demonstrating use of the Edit object  DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.title←'Edit Example'  DEMO.myEdit.New 'Edit' ⋄ DEMO.myEdit.where←2 1  DEMO.myEdit.text←'Some sample text'  ⍝  ⍝ Wait for the user to close the window  0 0⍴⎕WE DEMO ∇
align anchors aquaadjust autodraw border canundo caption children class color data doublebuffered dragsource droptarget enabled events extent font handle limit maxsize methods minsize name opened order pointer properties scale selection self seltext size sourceformats style tabstop targetformats text tie units visible where winptr
onChange onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onFocus onHide onKeyDown onKeyPress onKeyUp onMouseDown onMouseMove onMouseUp onOpen onSend onShow onUnFocus
Copyright © 1996-2010 MicroAPL Ltd