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


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

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

(* WSEV_KEY_HOOK触发器的事件处理例 *)
(* 设置WSEV_KEY_HOOK触发器         *)
...

let hookop obj =
  (* 获取键盘码 *)
  let key = get_int (_WSGIappKeyboard '() -> getKey () ) in
  if (((key >= get_int _WSK_0) && ( key < get_int _WSK_9)) ||
     ((key >= get_int _WSK_KP_0) && ( key < get_int _WSK_KP_9)) ||
     (key = get_int _WSK_plus)  || (key = get_int _WSK_minus) ||
     (key = get_int _WSK_BackSpace) || (key = get_int _WSK_Delete) || (key =
get_int _WSK_Insert) ||
     (key = get_int _WSK_space) || (key = get_int _WSK_Up) || (key = get_int
_WSK_Down) ||
     (key = get_int _WSK_Left) || (key = get_int _WSK_Right) || (key = get_int
_WSK_Return) ) then begin
    (* 只接受关心的键盘输入 *)
  end else begin
    (* 屏蔽其他键盘输入 *)
    ignore(_WSGIappKeyboard '() -> setKey (0));
  end
  ()

let _ = Callback.register "hookop" hookop

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

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