![]() | Programming Guide | WideStudio/MWT Index Table of contents |
判断鼠标按键
在事件过程或其他场合,时常需要进行鼠标按键的判断。如下例所示, 可以通过全局鼠标实例,判断当前点击的鼠标按键。(*----------------------------------------------------------*) (*Function for the event procedure *) (*----------------------------------------------------------*) open Swig open Mwt open Mwtlib let btn_ep obj = let status = _WSGIappMouse '() -> getStatus () in begin (* A *) if ((get_int status) land (get_int _WS_MOUSE_BTN1)) <> 0 then (* B *) print_string(" 点击鼠标左键时执行的处理 "); if ((get_int status) land (get_int _WS_MOUSE_BTN2)) <> 0 then (* C *) print_string(" 点击鼠标中键时执行的处理 "); if ((get_int status) land (get_int _WS_MOUSE_BTN3)) <> 0 then (* D *) print_string(" 点击鼠标右键时执行的处理 "); print_newline(); end; () let _ = Callback.register "btn_ep" btn_ep首先,如A 所示获得鼠标的点击状态。C、D、E 对鼠标按键进行逐个判断。 由于需要判断是否有多个按键被同时点击、所以需要使用“==”(比较), & (与操作)进行判断。
Copyright(C) WideStudio/MWT Development Team, 1999-2005 | Last modified: Jul 31, 2005 |