This tag allow you to define a routine which can constrain which keypresses
should be reacted to by the edline object, or even give a special meaning
to certain keypresses. The tag needs one parameter, which is a function of
type "Error (*)(PWObject object, EdlineInfo *info)". This function is
called each time a key is pressed inside the edline object, and once before
the editing starts (with a nul key).
To make it somewhat easier to use, there are some standard builtin
routines to constrain the text in the edline object to numbers, either
natural numbers (PW_EDLINE_ACTION_TEST_NATURAL), integers
same as natural, but including sign)
(PW_EDLINE_ACTION_TEST_INTEGER), of floating point numbers (also
including decimal point) (PW_EDLINE_ACTION_TEST_FLOAT).
The test routine is passed a structure which contains details about the
current value of the string, its maximum length, current length, the
cursor position and the key which was pressed. Depending on these values,
the routine can do one of three things :
- Accept the keypress. The function decides that the keypress is valid
and should be reacted to in the standard way. You can also
change the key to something else (e.g. convert to upper case).
In this case, the function should return PW_EDLINE_TEST_ACCEPT.
Only the key may be modified in the EdlineInfo
structure.
- Discard the keypress. The function decides that the key which was
pressed is not allowed in this edline. This can for example be used
to make sure no letters are inserted in a number, or that you can only
have one decimal point in a floating point number. The function should
return PW_EDLINE_TEST_NOACCEPT and should not modify the
EdlineInfo structure.
- Give a different meaning to the key which was pressed. You can change
the string which is displayed and/or the current cursor position. The
function should return PW_EDLINE_TEST_CHANGE. The
EdlineInfo may be modified (this is intended). However, you
should take care that no more than maxlength bytes are used
in the string, and the length==strlen(string).