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:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=uCNPAuf6jVGQh6si35eZR0UIKv6JQBH+eluQkt3bdww=; b=GtiimL4loQPCOm48vJ1R/vM+WZkWO4gIRPW9NhPhj4X5TuHkF2ZBPMpgo0Fuq7lRtc 9mhy43QW4eD2TSOdi+yT8RKYlvm5q4mbmM2zW694oPd+qFMG2RT3llO0mA4OJ4UF9VHO ZUcZl0gh8SUb3M8yxz6fu21zQkgv0A4EBSEBk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=rjuFMyUY9G1a6y/c+74hQbtoV2bOYYEoqf9sbiheqFo5XEHFeLUVmHOydtV/fQ4zwN pA/XGngYgfYHbqmLi+6oDCFyAAlNQ59TG6l1gci09XYudE/cu/mMsdJPTV7sNQxBtBVz 00dCJ1m467L9SkekNe022+YTtJPxhv9rR40gw= Date: Fri, 7 Nov 2008 14:43:15 -0600 From: Peter Groves To: "Angela Zhu" Subject: Re: [Lablgtk] How to get mouse position continuously without events Message-Id: <20081107144315.6462ea61.pdgroves at gmail.com> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: lablgtk at yquem.inria.fr The Widget class has a method called "pointer" that gives the location of the mouse pointer. Here is the doc from the gtk core library: http://library.gnome.org/devel/gtk/2.14/GtkWidget.html#gtk-widget-get-pointer I have not tried to use it using lablgtk, however, so I can't tell you much about how to use it. -Peter On Fri, 7 Nov 2008 11:56:34 -0600 "Angela Zhu" wrote: > 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 Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk