| WideStudio Programming Guide | WideStudio Index Table of contents

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

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

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

>     def hookop(object)
>       # 获取键盘码
>       key = Mpfc::WSGIappKeyboard().getKey()
>       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
>       end
>       # 屏蔽其他键盘输入
>       Mpfc::WSGIappKeyboard().setKey(0)
>     end

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

Document Release 3.70 for WideStudio ver 3.70, May 2004

WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2004 | Last modified: May 25, 2004