Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:mime-version:content-type; bh=MXOP1b5c3oyUIEkR8Frd8+eHGfPszsQEVmAd69bS/KA=; b=nLzkunz+PjsdCAnOcR3DAJwkVbqK6TLlsSa3VdbFwuKErtBoYYChlhrv3Cip62bx6F Izva6W7a25wDXldBJBdZMxMPT4TrzX7w+lbzX4wx3ENcIjUCCSQqe7cn/bZgGmCIcarT RbLOpHQu88xBYs+DXYYxXeKjW2Ct6OVpvtPvc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:mime-version:content-type; b=eVZqr/r+t2d6qhcHvIUQTVwbcg6Kq0gJnTdPBXKl/2Uk8LYZ5N96fW4Md4vN2E7Kvq J3i0iKB4Y3LCaQM7RhHTKtNcr3GicCqHYFXJOFOpuUk/U/THK3APca8aRqrryc6BTRIF 9fbMtP5qg/ZvfWK06qQXthVGZT2yt6b8IrvUM= Message-ID: Date: Fri, 7 Nov 2008 11:56:34 -0600 From: "Angela Zhu" To: lablgtk at yquem.inria.fr MIME-Version: 1.0 Cc: Walid Taha , Gregory Malecha Subject: [Lablgtk] How to get mouse position continuously without events Content-Type: multipart/mixed; boundary="===============0002254551==" Mime-version: 1.0 --===============0002254551== Content-Type: multipart/alternative; boundary="----=_Part_51376_21807114.1226080594105" ------=_Part_51376_21807114.1226080594105 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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/ ------------------------------------------ ------=_Part_51376_21807114.1226080594105 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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/
------------------------------------------
------=_Part_51376_21807114.1226080594105-- --===============0002254551== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk --===============0002254551==--