Combobox Gadgets
- Last UpdatedNov 01, 2022
- 2 minute read
A COMBObox is a combination of an option gadget and text field. It can be defined by the command:
combo .Colour tagwid 5 'Colour' scroll 20 width 5
When the ComboBox is editable(default), with the drop-down list closed, you can search for a required option by typing the first few letters into the display field and clicking the down-arrow. The list will open with the first matching option highlighted. This is useful for large lists.
The display field is accessible to you, who can edit the contents by typing or pasting text into the field. It behaves in a similar way to a Text field, and can be 'actioned' by 'Tabbing away', or by clicking another gadget or form, or by pressing the Enter key. When 'actioned', a VALIDATE event is raised. You can trap this event by assigning a PML Open callback to the gadget. This allows you to give meaning to the action of typing text into the display field. The Open callback is necessary to differentiate the VALIDATE event from the SELECT and UNSELECT events.
On receipt of the VALIDATE event, your callback method can retrieve the displayed text by means of the DisplayText method and decide what action is associated. Additionally you can assign a popup menu to the gadget, which gives you the choice of several actions.
For example, you might append the current display text to the drop-down list as a new choice, possibly making sure that there are no duplicate entries. An assigned popup menu could allows options to be removed from the drop-down list and the editable status of the combobox to be toggled.
(PML example code is available as User Manual example Layout2.pmlfrm which can be obtained from AVEVA's support web site.)