wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Form/SetKeyEvent

SetKeyEvent

CForm member function to set an event to alter received keypresses before processing by the form.

void CForm::SetKeyEvent(int (*pEventKey)(CForm* pForm, CFormItem *pItem, int nData))

Parameters

pEventKey = Event to handle keypresses

Return Value

This function may return 0 to disregard the keypress or the ASCII value to be processed as the key.

Remarks

Examples

int DontAllowZKey(CForm* pForm CFormItem* pItem, int nData)
{
   if(nData == 'Z')
      return 0;
   else
      return nData;
}

void CreateNoZForm(void)
{
    FORM_INIT(NoZ, EventNoZShow, NULL, NULL, NULL, nFormFlgNone);
    FORM_ADD_INPUT(NoZ, ID, FONT_WIDTH * 2, FONT_HEIGHT * 3, "Input: ", 10, 0, 0, NULL, g_strID, NULL, "Enter ID, 'Z' not allowed");

    formNoZ.SetKeyEvent(DontAllowZKey);

    FORM_SHOW(NoZ);
    FORM_RUN(NoZ);
    FORM_HID(NoZ);
}

See Also

Last modified 5 years ago Last modified on 06/27/19 08:54:11
Note: See TracWiki for help on using the wiki.