TAutoGet / TGetList
Source: source/classes/autoget.prg
TAutoGet inherits from: TGet | TGetList inherits from: TControl
TAutoGet extends TGet with an autocomplete dropdown list that appears as the user types, showing matching items from a data source (array or hash). The dropdown is implemented by TGetList, a companion class that renders a scrollable, gradient-styled item list with hover highlighting and keyboard navigation.
TAutoGet DATA Members
| DATA | Type | Description |
|---|---|---|
uDataSource | Array/Hash | Source data for autocomplete suggestions |
cField | Character/Numeric | Field or column index within the data source |
oList | Object | Reference to the TGetList dropdown window |
nLHeight | Numeric | Maximum height of the dropdown list (default 170) |
bCreateList | Block | Code block to re-filter the list as the user types |
aGradList | Array | Gradient definition for the list background |
aGradItem | Array | Gradient definition for individual items |
nClrLine | Numeric | Border/separator line color |
nClrSel | Numeric | Highlight color for selected item |
nClrText | Numeric | Text color in the list |
TGetList DATA Members
| DATA | Type | Description |
|---|---|---|
oGet | Object | Reference to the parent TAutoGet control |
nRowHeight | Numeric | Height of each list item row in pixels |
nMaxHeight | Numeric | Maximum allowed height for the list window |
nFirstRow | Numeric | First visible row index (for scrolling) |
nRowAt | Numeric | Currently highlighted row |
Methods
| Class | Method | Description |
|---|---|---|
| TAutoGet | New( nRow, nCol, bSetGet, oWnd, nW, nH, cPict, ... ) | Create a new autocomplete GET control |
| TAutoGet | ReDefine( nId, bSetGet, oWnd, ... ) | Redefine from a dialog resource |
| TAutoGet | SetList( uDataSource, cField ) | Set the data source and display field |
| TAutoGet | OpenList( nKey, nFlags ) | Open the dropdown suggestion list |
| TAutoGet | CloseList() | Close the dropdown list |
| TAutoGet | CreateList() | Create or refresh the dropdown list |
| TGetList | New( nTop, nLeft, oWnd, nW, nH, oGet, aGradItem, aGradList, nClrLine, nClrText, nClrSel ) | Create the dropdown list window |
| TGetList | SetList( uDataSource, cField ) | Populate the list from array or hash source |
| TGetList | Adjust() | Recalculate row height and window size |
| TGetList | GoDown() / GoUp() | Navigate the list with keyboard |
| TGetList | Paint() / PaintData( hDC, nAt ) | Draw the list with gradient backgrounds |
Example: Autocomplete GET
#include "FiveWin.ch"
function Main()
local oWnd, oGet, cVar := Space( 30 )
local aCities := { "Madrid", "Barcelona", "Valencia", "Sevilla", "Bilbao" }
DEFINE WINDOW oWnd TITLE "TAutoGet Demo" SIZE 400, 150
@ 30, 30 AUTOGET oGet VAR cVar ;
ITEMS aCities ;
OF oWnd ;
SIZE 200, 20
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Call
SetList( aData, cField )to supply the autocomplete data source. The source can be an array of arrays or a hash, withcFieldselecting the display column. - The
bCreateListblock is evaluated each keystroke to filter the list. The default block restores the original data source when the list closes. - TGetList draws a gradient-styled overlay window with rounded item selection highlighting.
- Keyboard navigation (Up/Down arrows) scrolls through the list; Enter or click selects an item and closes the list.