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

Version 3 (modified by Don Wilson, 5 years ago) ( diff )

--

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

Note: See TracWiki for help on using the wiki.