![]() | Programming Guide | WideStudio/MWT Index 目次 |
インプットフィールドでキー入力を選別するには
インプットフィールドでキー入力を選別するには、キーフックトリガでイベ ントプロシージャを作成します。(* キーフックのイベントプロシージャのサンプル *) (* 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このサンプルは、数字入力のみを行いたいインプットフィールドを実現しま す。キーボードインスタンスに対して、_WSGIappKeyboard '() -> getKey() 関数により現在入力され つつあるキーを選別して、いらないキーの場合、 _WSGIappKeyboard '() -> setKey(0) を実行して、 入力キーコードを塗りつぶし、入力がなかったように装います。
Copyright(C) WideStudio/MWT Development Team, 1999-2005 | Last modified: Jul 31, 2005 |