The keys handlers can be queried, added and replace an removed from the internal keyboard dictionary. See the example.

oTb:SetKey( K_TAB, {| oTb, nKey | -1 } )

An default key handler can be declared by specifyin a value of 0 for <nKey>. It associate code block will be evaluated each time TBrowse:Applykey() is called with an key value that is not contained in the dictionary. For example

oTb:SetKey( 0, {| oTb, nKey | DefKeyHandler( otb, nkey } ) This call the a function named DefKeyHandler() when nKey is not contained in the dictionary.

Rate this:

SACHOICE()
Short:
------
SACHOICE() Achoice replacement, uses TBROWSE, codeblock
Returns:
--------
<nSelection> => selection, 0 if none
Syntax:
-------
SACHOICE(nTop,nLeft,nBottom,nRight,aOptions,[bKeyBlock],[nStart],[@nRow],;
[nMRow, nMCol],[bMouse])
Description:
------------
This semi-replaces ACHOICE() by using TBROWSE
instead, and by accepting an exception codeblock instead of a user
defined function.
<nTop,nLeft,nBottom,nRight> are the dimensions.
<aOptions> is the array. It need not be of type
Character.
First-letter presses go to the next matching letter
of the next character-type element.
Up/down/home/end/pageup/pagedown are used to position the
cursor. ENTER returns the current selection. Escape returns 0.
The screen is not saved and restored. This is a
building block function, like ACHOICE(), so save and restore the
screen, draw a box around it, etc, as you would ACHOICE().
[bKeyBlock] a codeblock which will be executed if an
exception key is received (any key not otherwise meaningful). The
codeblock will be evaluated and will be passed:
1. current element #
2. exception key value
3. the tbrowse object
as parameters.
[nStart] is an optional starting element. Default is 1.
[@nRow] is an optional starting row. Default is 1. Pass by reference
to retain value between calls.
[nMRow, nMCol] (new in 3.5) Directs sachoice() to draw
the "[.][.]" for mouse up/down at nMrow, nMCol, and to be aware of mouse
clicks on these buttons. (the screen under the arrows is saved/restored)
[bMouse] is a codeblock to evaluate mouse clicks other than those
meaningful to sachoice(). The codeblock is evaluated as follows:
eval(bMouse,mouserow, mousecolumn)
Examples:
---------
USE CUSTOMER
aFlds := afieldsx()
bExcept := {|e,k|msg("You pressed ",str(k))}
?SACHOICE(10,10,20,12,aFlds,bExcept)
//to retain element and position between calls
nSelect := 1
nRow := 1
aMeals := {"Pizza","Chicken","Chinese"}
while nSelect > 0
nSelect := sachoice(10,10,20,20,aMeals,nil,nSelect,@nRow)
// code
endif
Notes:
-------
This will be a lot easier to mouse-ize than ACHOICE.
(or is that RAT-ify..)
Source:
-------
S_ACHOI.PRG

Rate this:

MCHOICE()
Short:
------
MCHOICE() Does a boxed, achoice() style popup on an array
Returns:
--------
<expN> Achoice selection
Syntax:
-------
MCHOICE(aOptions,[nTop,nLeft],[nBottom,nRight],[cTitle],[lTrigger],;
[nStart],[@nRow],[aSelectable])
Description:
------------
Provides a box for selection from array <aOptions> of
character elements.
[nTop,nLeft] may be specifed to determine the
starting top and left of the popup box.
[nBottom,nRight] may be specified to complete the box
dimensions.
Default box dimensions are centered on the screen. If the dimensions
passed are not wide enough to display the mouse hot areas on the
bottom, the box is widened and centered on the screen.
[cTitle] is a string to display at the top of the box.
[lTrigger] determines (yes or no) whether a return is
to be executed on a first letter match.(default .f.)
[nStart] optional starting element (default 1)
[@nRow] optional starting row. Pass by reference to retain value
between calls.
[aSelectable] is an array of logicals that determines which items
are selectable. This array must be the same size as [aOptions], and
all elements must be either True or False, not NIL. Where an element
is False, the corresponding element in [aOptions] will be dimmed
and will emit a BEEP when you attempt to select it.
Examples:
---------
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals)
// or box with title
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals,,,,"Meals")
// or box with title, first letter match = return and top/left specified
aMeals := {"Pizza","Chicken","Chinese"}
nSelect := mchoice(aMeals,10,10,,,"Meals",.t.)
//to retain element and position between calls
nSelect := 1
nRow := 1
aMeals := {"Pizza","Chicken","Chinese"}
while nSelect > 0
nSelect := mchoice(aMeals,,,,,"Meals",.t.,nSelect,@nRow)
// code
endif
Notes:
-------
Bottom of window adjusts (shrinks) to adjust to array
size if needed.
Now uses Tbrowse() instead of ACHOICE().
Source:
-------
S_MCHOI.PRG