WideStudio Programming Guide

| WideStudio Programming Guide | WideStudio Index Table of contents

> ## 输入字段中键盘输入的处理

> 通过WSEV_KEY_HOOK触发器的事件处理，对输入字段中键盘输入进行处理。

>     //WSEV_KEY_HOOK触发器的事件处理例
>     //设置WSEV_KEY_HOOK触发器
>     #include
>     ...

>     void hookop(WSCbase* object){
>       //获取键盘码
>       long key = WSGIappKeyboard()->getKey();
>       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 ){
>         //只接受关心的键盘输入
>         return;
>       }
>       //屏蔽其他键盘输入
>       WSGIappKeyboard()->setKey(0);
>     }

> 上述的例子中，只接受数字输入。通过键盘对象的getKey()函数获得当前的键盘输入码。 通过 setKey(0) 函数将不需要的输入内容删除。

Document Release 3.70 for WideStudio ver 3.70, Feb 2004

WideStudio documents index | Table of contents

Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004