StepChoiceSelection

Forms, interaction

Description

Moves the selected option of a visible, writable choice field by the requested delta

The current field value is matched against the export names and display names of all configured options, and when no option matches, a negative delta jumps to the last option while a non-negative delta selects the first

The resulting target is clamped into the option list, the new value is taken from the option's export name or its display name when no export name exists, and an unchanged value completes without any action or edit

A changing value focuses and edits the field, dispatches the Widget /K keystroke action, stores the new transient value and finishes with CommitEdit, so /V, /F and OnValueChanged run through the normal commit path

When /K is vetoed for a field that was not being edited before, the freshly started edit is cancelled again

Declaration

function StepChoiceSelection(FieldIndex, Delta: Integer): Integer;

Parameters

FieldIndexField or temporary Widget index of a visible, writable choice field
DeltaNumber of options to move, negative for backward and positive for forward steps

Return value

Returns 1 when the selection step completed or the value already matched, and 0 when the field is invalid, not a choice field, read-only, has no options or a dispatched action or commit rejected the change

Example

// Keyboard path used by DispatchInputEvent for choice fields
Steps := -1; // fikUp moves to the previous option
Handled := Session.StepChoiceSelection(FieldIndex, Steps) = 1;

See also

CommitEdit, SetEditValue, DispatchInputEvent, BeginEdit, OnValueChanged