Style Attribute
Data Type: integer
4GL Access: RW
The Style attribute affects the behavior of the OptionField. Possible values are:
OF_NORMAL
Specifies that the OptionField takes on only the values in the ValueList (the values in the drop-down list of the OptionField)
OF_EDITABLE
Specifies that the user can enter a value in the OptionField. When the user enters a new value in the field, there is a SetValue event for the field, and the field takes on the value the user has entered.
OF_AUTOFIND
Specifies that the user can enter a value in the OptionField. As the user types, the closest match from the OptionField list is highlighted. When the user presses Enter or tabs out of the OptionField, the value selected becomes the current value of the OptionField.
Although the matching algorithm is more intuitive when the OptionField list is sorted in lexicographical order, it works on an unsorted list.
When an OptionField gets the input focus, the current item is highlighted. As the user types, the list is searched for an item with an initial string that matches what the user has typed. The list is treated as circular, and with one exception, the search starts with the current item, wrapping from the end to the beginning of the list if necessary. All comparisons ignore case.
As the user continues to type, the OptionField always contains an item from its list. Usually a trailing substring is highlighted.
Descriptions of system constant values and their numeric equivalents are listed in
OptionField Settings (see
OptionField Settings).
The best way to illustrate the matching algorithm is with an example.
Examples:
Consider an OptionField with the following list:
Aardvark
Apple
Aztec
Ball
Ballast
Belter
Bismuth
Castle
Cornwall
Corn
Couple
The list is not sorted: “Cornwall” precedes “Corn.”
In the following examples, boldface type indicates the part of the text that is highlighted. Most examples have the form:
Current State Keystroke Result
Suppose the user enters the field when “Aardvark” is the current item. The entire word “Aardvark” is highlighted. As the user types, the following changes occur:
Aardvark a Aardvark
Aardvark p Apple
If the user then types “x”, there is no possible match.
Apple x Apx
“Apx” appears briefly, there is a beep, and the OptionField returns to its previous state:
Apple
Now consider the following sequence:
Aardvark c Castle
Castle o Cornwall
“Cornwall” is selected because it is the first match in the list after “Castle.” Suppose, however, that the user really wants “Corn.”
Cornwall r Cornwall
Cornwall n Corn
The system always searches first for an exact match for what the user has typed.
The caret is always at the end of the text unless the user moves it using the arrow keys. If the user really wants “Cornwall,” the following works:
Corn w Cornwall
When the user goes too far in the list, the problem of backing up arises. Consider the following:
Aardvark a Aardvark
Aardvark z Aztec
Suppose that the user wants to get to Apple from this state. A natural thing to do would be to press Backspace or Delete. However, following the rules described so far, deleting “tec” would leave “Az” in the buffer, and the next match is “Aztec.” Therefore, the behavior is different when the user hits Backspace or Delete.
Aztec Backspace Aztec
The highlighted portion now includes the last character that the user typed, and the user can do the following:
Aztec p Apple
The Delete key has the same function as the Backspace key. Note, however, that the result might be different with a randomly ordered list.
Backspace and Delete let the user back up several times:
Apple b Ball
Ball i Bismuth
Bismuth Backspace Bismuth
Bismuth Backspace Bismuth
Bismuth a Aardvark