Edit mode

mode = flags


Applicable to:

listboxes; tables; textboxes


DEFAULT

The default edit mode is defined by the flags set in sys.EditMode, which itself defaults to all flags off.

Edit mode flags affect the behaviour of the program when data is input into a textbox or LIST_EDIT type listbox. Unless otherwise stated, the flags are for use with these two control types only. Edit mode flags may also be used for other purposes: for example, to prohibit a table, textbox or listbox from being updated by the user, or to enable multiple selections. Any combination of these flags may be used, and they may appear in any order.

If more than one flag is required, they must be separated by the bitwise or operator |, as shown in this example:

mode = EM_AUTOCR | EM_EXTEND

Any flags assigned to an individual control are combined with those assigned to sys.EditMode, rather than overriding them. Thus in this example:

sys.EditMode = EM_AUTOCR
...

+textbox Box3 at 35,72 {
     mode = EM_EXTEND
}

the textbox has both EM_AUTOCR and EM_EXTEND set.

Mode flags are defined in the include file $SCULPTOR/include/sculptor.h with the prefix EM_.

The available flags are:

EM_AUTOCR

Causes an automatic TAB to the next control to be generated when a character is entered into the last character position of the box. If this flag is not set, input into the box must be completed with the TAB, RETURN, DOWN ARROW or RIGHT ARROW key. Note that if a control is exited in this way, the keycode(1) function returns the code for TAB, not for the last character actually typed.

EM_NOCLEAR

Prevents the current contents of a box from being highlighted when the box receives focus. Normally the entire contents are highlighted and any keypress other than a movement or editing key causes them to be replaced by the character typed. This flag is ignored if the the box gains focus by means of a mouse click from the user. In this case the user must click and drag to highlight text.

EM_EXTEND

Start input at end of text. The cursor goes to the end of any current text in the box. This flag is ignored if the the box gains focus by means of a mouse click from the user, in which case the cursor appears at the point of the click.

EM_NOECHO

Don’t echo the input to the screen. If the linked field has an e (suppress echo on input) flag in its definition, then EM_NOECHO is assumed and need not be specified. See Field flags.

EM_READONLY

This flag is available for use with textboxes, tables and with all listbox types. It prevents the user from updating the field contained in the box, or from changing the selection. It is possible to move the cursor to the control, but only movement keys (RETURN, TAB, BACKSPACE etc.) can be typed. This mode is useful for the creation of a list of values through which the user can browse using the cursor keys, selecting one value by pressing the RETURN key. See the keycode() function for details of how to determine which key the user pressed. This flag does not cause a box to differ visually from other boxes. The style flag WS_DISABLED or the disable command can be used if required, to give a control a greyed appearance.

EM_MULTIPLE

This flag is only used with tables and LIST_BOX type listboxes. It allows multiple selection of values.

EM_NO_HIGHLIGHT

Tables only. Don’t highlight the selected line(s). Functions relating to the selected line (e.g. is_selected(), set_selected()) work exactly as if the flag were not set.

EM_CELL_SELECT_NO_HIGHLIGHT

Editable tables only. If an editable cell has focus, don’t highlight the entire line. A line can be highlighted by clicking on a non-editable cell.

EM_SYNC_SOURCE

Tables only. Update both the source and display object when a cell loses focus. If this flag is not set, only the display object is updated.

EM_LOWERCASE, EM_UPPERCASE

Fold input to lower or upper case. This flag is used only with LIST_EDIT type listboxes. In a textbox, the linked field format or textbox format is used to control folding of input.


RELATED TOPICS

sys.EditMode

Listbox edit mode

Table edit mode

Textbox edit mode


Modifying edit mode at run time

It is not possible to override a flag assigned to sys.EditMode in an object’s definition, only to add more flags. However, flags may be freely removed and added at run time. As several flags may be active at any time, the | (bitwise or) and &~ (bitwise and not) operators are used to add and remove flags. Changes to an object’s edit mode should therefore use the constructions:

Adding an edit mode flag
object_id->mode = object_id->mode | flag [ | flag] …
Removing an edit mode flag
object_id->mode = object_id->mode &~ ( flag [ | flag] …)

The changes are effected immediately; the object need not be re-created.

RELATED TOPICS

Modifying a property at run time


Retrieving edit mode at run time

Use the following form to test an object for a edit mode flag at run time:

object_id->mode &

The bitwise and operator (&) is used rather than the equals to operator (=) because several flags may be assigned at any one time. The clause evaluates to non-zero (TRUE) if the object has the edit mode flag being tested, otherwise zero (FALSE).

EXAMPLE

switch(NameBox->mode & EM_NOECHO) {
     case = 0:
          caption "Box has echo disabled"
          break
     default:
          caption "Box has echo enabled"
          break
}

RELATED TOPICS

Property clauses

sys.EditMode

Retrieving a property at run time