IupMask - controle

IUP - Portable User Interface

iupMask

Functions to associate an input mask to a IupText or a IupMatrix element.

These functions are included in the Controls Library.

See the Pattern Specification for information on patterns.

Functions

int iupMaskSet(Ihandle *h, char *mask, int autofill, int casei) [in C or in IupLua]
int iupMaskMatSet(Ihandle *h, char *mask, int autofill, int casei, int lin, int col); [in C or in IupLua]

These functions are responsible for setting the mask to be used.

h: Ihandle of IupText or IupMatrix
mask: Mask to be used
autofill: When “1”, turns the auto-fill mode on. In auto-fill mode, whenever possible, literal characters will be automatically added to the field
casei: When “1”, uppercase or lowercase characters will be treated indistinctly 
lin, col
: Line and column numbers in the matrix

They return 1 if the mask is set, or 0 if there is an error (e.g., invalid mask).

int iupMaskSetInt(Ihandle *h, int autofill, int min, int max); [in C or in IupLua]
int iupMaskSetFloat(Ihandle *h, int autofill, float min, float max); [in C or in IupLua]
int iupMaskMatSetInt(Ihandle *h, int autofill, int min, int   max, int lin, int col); [in C or in IupLua]
int iupMaskMatSetFloat(Ihandle *h, int autofill, float min, float max, int lin, int col); [in C or in IupLua]

These functions set a mask that defines a limit to the typed number. Works only for integers and floats. Limitations: since the validation process is performed key by key, the user cannot type intermediate numbers (even inside the limit) if they are not following predetermined rules

h: Ihandle of IupText or IupMatrix
autofill: When “1”, turns the auto-fill mode on. In auto-fill mode, whenever possible, literal characters will be automatically added to the field
min: Minimum value accepted in the field
max: Maximum value accepted in the field
lin, col: Line and column numbers in the matrix

They always return 1.

int iupMaskCheck (Ihandle *h); [in C or in IupLua]
int iupMaskMatCheck(Ihandle *h, int lin, int col); [in C or in IupLua]

These functions verify if what was typed by the user is valid for the defined mask.

h: Ihandle of IupText or IupMatrix
lin, col: Line and column numbers in the matrix

They return 1 if the text satisfies the mask, or 0 otherwise.

int iupMaskGet(Ihandle *h, char **val); [in C]
int iupMaskGetFloat(Ihandle *h, float *fval); [in C]
int iupMaskGetInt(Ihandle *h, int *ival); [in C]
int iupMaskMatGet(Ihandle *h, char **val, int lin, int col); [in C]
int iupMaskMatGetFloat(Ihandle *h, float  *fval, int lin, int col); [in C]
int iupMaskMatGetDouble(Ihandle *h, double *dval, int lin, int col); [in C]
int iupMaskMatGetInt(Ihandle *h, int *ival, int lin, int col);

These functions check if the mask is complete, and they retrieve the field’s value in only one call.

h: Ihandle of IupText or IupMatrix
val, fval, ival: Pointers used to complete the return value
lin, col: Line and column numbers in the matrix.

They return 1 if the text satisfies the mask, or 0 otherwise.

Notes

User callbacks previously associated to the text-editing field or to the Matrix field (that is, before the iupMaskSet function is called) will be called by the library if the pressed key satisfies the mask. Attention: for the callback to be actually called, the user must call not only IupSetAttribute, but also IupSetFunction.

To make the use of masks simpler, the following predefined masks were created:

IUPMASK_FLOAT - Float number
IUPMASK_UFLOAT - Float number with no sign
IUPMASK_EFLOAT - Float number with exponential notation
IUPMASK_INT - Integer number
IUPMASK_UINT - Integer number with no sign

Examples