How to get mouse position continuously without events
"Angela Zhu" <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am writing a simulation program, where basically, the program has a number
of
time steps. At each time step, it tries to get the current position of
mouse,
do some computation, and update a gui with the result computed.
What I need is a function that can get the current position of mouse without
any
events. I know, for example, the following code will work.
But is there a way to avoid events, but just get the mouse position?
Thanks a lot in advance!
method handle_event = function
| info (* : GdkEvent.Motion.t *) ->
let new_x = (GdkEvent.Motion.x info) -. 350.
and new_y = (GdkEvent.Motion.y info) -. 350.
in
print_string "\nfollow mouse\n"; flush stdout;
inputs.(0)#move_to new_x new_y;
false
| _ -> false
ignore (canvas#event#connect#motion_notify
~callback:(self#handle_event));
--
Regards,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------
_______________________________________________
Lablgtk mailing list
[email protected]
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk