(************************************************************ whatsmotion.ml Created : Sun Feb 23 04:04:36 2003 Last modified: Sun Feb 23 04:07:41 2003 Compile: ocamlc.opt -I +labltk labltk.cma whatsmotion.ml -o whatsmotion # FTP Directory: sources/ocaml # ************************************************************) (** マウスの移動を捕捉 @author Takashi Masuyama *) open Tk let _ = let window = openTk () in let canvas = Canvas.create ~background:`White ~name:"canvas" ~height:500 ~width:500 window in bind ~events:[`Motion] ~extend:false ~fields:[`MouseX; `MouseY] ~action:(fun e -> let x = e.ev_MouseX in let y = e.ev_MouseY in Printf.printf "Moving (%d, %d)\n" x y; flush stdout) canvas; pack [canvas]; mainLoop ()