From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,be6e28f854440947 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news3.google.com!feeder.news-service.com!kanaga.switch.ch!switch.ch!hefestos.uned.es!news.uv.es!not-for-mail From: Manuel Collado Newsgroups: comp.lang.ada Subject: Re: How to get the mouse position with JEWL? Date: Thu, 21 Oct 2010 00:22:56 +0200 Organization: Universitat de Valencia Message-ID: References: <057188e8-a7c9-4aeb-968c-ccdf720bd0fc@t20g2000yqa.googlegroups.com> NNTP-Posting-Host: 83.46.235.180 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: peque.uv.es 1287613498 7352 83.46.235.180 (20 Oct 2010 22:24:58 GMT) X-Complaints-To: newsmanager@uv.es NNTP-Posting-Date: Wed, 20 Oct 2010 22:24:58 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3 In-Reply-To: <057188e8-a7c9-4aeb-968c-ccdf720bd0fc@t20g2000yqa.googlegroups.com> Xref: g2news2.google.com comp.lang.ada:15606 Date: 2010-10-21T00:22:56+02:00 List-Id: El 20/10/2010 19:20, tolkamp escribi�: > On 20 okt, 13:42, Manuel Collado wrote: >> El 20/10/2010 11:04, tolkamp escribi�: >> >>> I use JEWL in several of my applications. >>> Now I try to get the mouse position within a JEWL canvas by using the >>> function "End_Point(Canavas)". >>> The resulting mouse position (x,y) is always zero. What is going wrong? >> >> Please try: >> >> point := Start_Point( canvas ); >> >> It works for me. >> > > Also when I try: > point := Start_Point( canvas ); > the x and y position remains zero. > > Here is the code: > > task body Task_2Hz is > My_Frame : Frame_Type; > My_Canvas : Canvas_Type; > My_Mouse_Position : Point_Type; > begin > accept Start do > My_Frame := Frame (1200, 500, "", 0); > My_Canvas := Canvas (Frame, (850,10), 300, 300); > loop > My_Mouse_Position := Start_Point(My_Canvas); > Put("Mouse-x = "); Int_Io.Put(My_Mouse_Position.x); New_Line; > Put("Mouse-y = "); Int_Io.Put(My_Mouse_Position.y); New_Line; > delay 0.5; > end loop; > end Task_2Hz; IIRC, you must wait for a mouse event before reading the coordinates. Here is a code fragment of a real program that uses a canvas. You may figure how to adapt it to your needs: function Get_Point return Point_Type is Here: Point_Type; begin loop case Next_Command is when Cmd_Mouse => exit; when Cmd_Quit => raise Program_Aborted; when others => null; end case; end loop; Here := Start_Point( Main_Canvas ); return Logical( Here ); end Get_Point; Hope it helps. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado