WideStudio/MWT Logo
WideStudio/MWT
Programming Guide
WideStudio/MWT Index
Table of contents


How to select the key events on the input field

You can select or reject/convert the key events on the input field with the event procedure by the WSEV_KEY_HOOK trigger.

//A WSEV_KEY_HOOK sample procedure.
//Set the input field with the WSEV_KEY_HOOK trigger.
#include "WSDkeyboard.h"
...

void hookop(WSCbase* object){
  //get the pressed key code.
  long key = WSGIappKeyboard()->getKey();
  //Choose the key which is a numerical code.
  if ( (key >= WSK_0    && key <= WSK_9   ) ||
       (key >= WSK_KP_0 && key <= WSK_KP_9) ||
        key == WSK_plus      || key == WSK_minus  ||
        key == WSK_BackSpace || key == WSK_Delete || key == WSK_Insert ||
        key == WSK_space     || key == WSK_Up     || key == WSK_Down   ||
        key == WSK_Left      || key == WSK_Right  || key == WSK_Return ){
    //dispatches..
    return;
  }
  //Reject the other.
  WSGIappKeyboard()->setKey(0);
}

This sample of the input field shows how to choose the key event. WSGIappKeyboard()->setKey(0) reject the key event which you do not need.

Document Release 3.90 for WideStudio/MWT ver 3.90, Jul 2005


WideStudio/MWT documents index | Table of contents

Copyright(C) WideStudio/MWT Development Team, 1999-2005 Last modified: Jul 31, 2005