WideStudio Programming Guide

| WideStudio Programming Guide | WideStudio Index Table of contents

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

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

>     # WSEV_KEY_HOOK触发器的事件处理例
>     # 设置WSEV_KEY_HOOK触发器
>     use mpfc;

>     sub hookop {
>       my ($object) = @_;
>       # 获取键盘码
>       $key = mpfc::WSDkeyboard_getKey( mpfc::WSGIappKeyboard() );
>       if  (($key >= $mpfc::WSK_0    && $key <= $mpfc::WSK_9   ) ||
>            ($key >= $mpfc::WSK_KP_0 && $key <= $mpfc::WSK_KP_9) ||
>             $key == $mpfc::WSK_plus      || $key == $mpfc::WSK_minus  ||
>             $key == $mpfc::WSK_BackSpace || $key == $mpfc::WSK_Delete ||
>             $key == $mpfc::WSK_Insert    || $key == $mpfc::WSK_space  ||
>             $key == $mpfc::WSK_Up        || $key == $mpfc::WSK_Down   ||
>             $key == $mpfc::WSK_Left      || $key == $mpfc::WSK_Right  ||
>             $key == $mpfc::WSK_Return ){
>         # 只接受关心的键盘输入
>         return;
>       }
>       # 屏蔽其他键盘输入
>       mpfc::WSDkeyboard_setKey( mpfc::WSGIappKeyboard(), 0);
>       return;
>     }
>     1;

> 上述的例子中，只接受数字输入。通过键盘对象的getKey()函数获得当前的键盘输入码。 通过 mpfc::WSDkeyboard_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