Edit Boxes
The following sections describe how to create, read and manipulate an edit box.
Creating an Edit Box
To create an edit box, use the following AiF escape sequence:
ESC_50 ; y ; x ; h ; wid {; vis} {; en} {; font} {; display} {; auto} {; acc} {; focus} {; edit} {; border}
{; scroll} ins/ovr w control-id {; contents} ESC\
Where:
y
|
y co-ordinate of top of box. |
|
x co-ordinate of left of box. |
|
Height of box, in rows. |
|
Width of box, in columns. |
|
1 = create hidden, 2* = create visible. |
|
1 = initially disabled, 2* = initially enabled. |
|
Selects font: 1* = terminal, 2 = system, 3 = 10pt Helvetica, 4 = 8pt Helvetica. |
|
1* = display contents normally. (The password character may be switched from asterisk to something else). |
|
1 = do not automatically (horizontally) scroll the box. |
|
1* = read/write access. |
|
1* = initially, contents not selected when box receives focus. |
|
1 = single line edit (* if height is 1).
|
|
1 = no border. The edit box height is exactly the multiple of character cells given. |
|
1= disable. |
|
1* = no scroll bars. |
|
Control id. |
|
Initial contents of box - optional. |
The height of the box that you pass relates to the height in character cells of the control, and not to the number of lines of text the control will hold.
Creating an edit box example
This example creates a 3x10 edit box at (12,10), id edit
, with a test string and scroll bar.
ESC_50 ; 12 ; 10 ; 3 ; 10 ;;;;;;;;;; 2 w edit ; Test text ESC\
Reading From an Edit Box
To read a value from an edit box, use the AiF escape sequences as described in the following sections.
In all cases, a value will be sent to the host. This return value is formatted as:
<STX><value> <CR>
If an error is detected in the arguments, the value returned is a single question mark (STX ? CR).
Reading a Line in an Edit Box
To read the contents of a given line in the box, use the following AiF escape sequence:
ESC_51 ; 1; max-len ; line w control-id ESC\
Where:
max-len
|
Is the maximum length of the text returned. (*=80). Remember to set |
|
Is the number (starting from 1) of the line you want. (*=all lines). For single line edits, For multi line edits, If If For example, if a multi-line edit contains 2 lines 'hello' and 'there', the reply would look like this: 2,hello<cr>there<cr> |
For example, to return the contents of line 3 of edit box 'ed', use:
ESC _ 51 ; 1 ;; 3 w ed ESC\
80 characters at most will be returned.
Examining Details of Lines
To read the number of lines in a box (always 1 for single line edit), use the following AiF escape sequence:
ESC_51 ; 2 ; w control-id ESC\
To read the current length of a given line, use the following AiF escape sequence:
ESC_51 ; 3 {; line} w control-id ESC\
Where:
|
The relevant line number (*=1). |
To read the line number of the first visible line in the box (for multi-line edits only), use the following AiF escape sequence:
ESC_51 ; 4 ; w control-id ESC\
Detecting Changes in an Edit Box
To return a flag that says if the edit box contents have been changed by the user.
ESC_51 ; 5 {; reset} w control-id ESC\
Where:
|
0* = do not reset changed flag. |
The value returned is '1' if no change, or '2' if changed.
Telling the Host Which Characters are Selected
To return a selection indication - telling the host which characters are selected (for single line edits), use the following AiF escape sequence:
ESC_51 ; 6 ; line w control-id ESC\
The value returned is two comma-separated integers n,w
, where:
n
|
The number of the first character in the selection (starting from1). |
|
The number of selected characters. |
If nothing is selected, the return value is '1,0'.
Manipulating an Edit Box
To manipulate an edit box, use the following AiF escape sequence features.
-
Setting contents in an edit box.
-
Limiting text entered.
-
Scrolling.
-
Changing ‘Password’ Character.
-
Setting Selection Range.
-
Using the Clipboard.
-
Initialising a Multi-line Edit Box.
There is no reply to this escape sequence.
Setting Contents in an Edit Box
To set the contents of an edit box, use the following AiF escape sequence:
ESC_52 ; 1 w control-id ; contents ESC\
Where:
|
The new contents of the edit box. |
Limiting Text Entered
To limit the amount of text that may be entered into the box, use the following AiF escape sequence:
ESC_52 ; 2 ; limit w control-id ESC\
Where:
|
The maximum number of characters. This is a total limit, not just the limit on a single line (multi-line edit box users take note). |
Scrolling
To scroll an edit box so that that the given line number is the first visible line (for multi line edits only), use the following AiF escape sequence:
ESC_52 ; 3; line w control-id ESC\
Where
|
The relevant line number. |
Changing “Password” Character
To change the “password” character, use the following AiF escape sequence:
ESC_52 ; 4; w control-id ; char ESC\
Where:
|
The password character. |
Setting Selection Range
To set the selection range (for single line edit boxes only), use the following AiF escape sequence:
ESC_52 ; 5; start ; len w control-id ESC\
Where:
start
|
The location (starting from 1) of the first character to be selected. |
|
The number of characters that are to be selected. |
Using the Clipboard
You can use the clipboard facilities as described:
To cut the selection in the edit box to the clipboard, use the following AiF escape sequence:
ESC_52 ; 6 w control-id ESC\
To copy the selection in the edit box to the clipboard, use the following AiF escape sequence:
ESC_52 ; 7 w control-id ESC\
To paste the clipboard contents into the edit box at the current insertion point, use the following AiF escape sequence:
ESC_52 ; 8 w control-id ESC\
This is ignored if the clipboard does not contain text.
To clear the current selection in the edit box (i.e., deletes it without placing it in the clipboard.), use the following AiF escape sequence:
ESC_52 ; 9 w control-id ESC\
Initialising a Multi-line Edit Box
To initialise a multi-line edit box with the contents of the named string list, use the following AiF escape sequence:
ESC_52 ; 10 w control-id; string ESC\
Where:
|
The string list id. |