![]() | Programming Guide | WideStudio Index 目次 |
インプットフィールドでキー入力を選別するには
インプットフィールドでキー入力を選別するには、キーフックトリガでイベ ントプロシージャを作成します。# キーフックのイベントプロシージャのサンプル # 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) を実行して、 入力キーコードを塗りつぶし、入力がなかったように装います。
Copyright(C) T. Hirabayashi, 2000-2004 | Last modified: Feb 25, 2004 |