WideStudio Programming Guide

| 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    and key <= mpfc.WSK_9   ) or
>            (key >= mpfc.WSK_KP_0 and key <= mpfc.WSK_KP_9) or
>             key == mpfc.WSK_plus      or key == mpfc.WSK_minus  or
>             key == mpfc.WSK_BackSpace or key == mpfc.WSK_Delete or key == mpfc.WSK_Insert or
>             key == mpfc.WSK_space     or key == mpfc.WSK_Up     or key == mpfc.WSK_Down   or
>             key == mpfc.WSK_Left      or key == mpfc.WSK_Right  or key == mpfc.WSK_Return ):
>         # 只接受关心的键盘输入
>         return;
>       # 屏蔽其他键盘输入
>       mpfc.WSGIappKeyboard().setKey(0);
>       return
>     mpfc.WSGFfunctionRegister("hookop",hookop)

> 上述的例子中，只接受数字输入。通过键盘对象的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