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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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: g2news1.google.com!postnews.google.com!a37g2000yqi.googlegroups.com!not-for-mail From: tolkamp Newsgroups: comp.lang.ada Subject: Re: How to get the mouse position with JEWL? Date: Sat, 23 Oct 2010 08:26:50 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6fa38e26-cf6a-4476-ab9a-e728a13a7667@a37g2000yqi.googlegroups.com> References: <057188e8-a7c9-4aeb-968c-ccdf720bd0fc@t20g2000yqa.googlegroups.com> <3bdec7d9-3dc6-44f1-be1b-8aa8dd539360@k22g2000yqh.googlegroups.com> NNTP-Posting-Host: 62.163.210.190 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1287847611 8234 127.0.0.1 (23 Oct 2010 15:26:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 23 Oct 2010 15:26:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a37g2000yqi.googlegroups.com; posting-host=62.163.210.190; posting-account=nZAcngoAAACcfYM9wDw3w9Z1XR3bObfs User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.1; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14696 Date: 2010-10-23T08:26:50-07:00 List-Id: On 23 okt, 00:15, Manuel Collado wrote: > El 22/10/2010 15:55, tolkamp escribi=F3: > [sinipped] > > >>> =A0 =A0 =A0 =A0 =A0My_Frame =A0 :=3D Frame (1200, 500, "", 0); > >>> =A0 =A0 =A0 =A0 =A0My_Canvas =A0:=3D Canvas (Frame, (850,10), =A0 =A0= =A0300, 300); > > This declares a non-interactive canvas. > > >>> loop > >>> =A0 =A0 =A0 =A0 =A0My_Mouse_Position :=3D Start_Point(My_Canvas); > > I assume Start_Point()/End_Point() are not available for My_Canvas in > this particular case. > > Please RTFM: > > -http://www.it.brighton.ac.uk/staff/je/jewl/docs/windows.htm#5 > -http://www.it.brighton.ac.uk/staff/je/jewl/docs/windows.htm#5.4 > > Quoting them: > > ----------------------------------- > 5. Canvases > ... > - Canvas (Parent, Origin, Width, Height, Font) > =A0 =A0Construct a canvas... MOUSE CLICKS AND KEY PRESSES ARE BOTH IGNORE= D... > > - Canvas (Parent, Origin, Width, Height, Command, Font) > =A0 =A0Construct a canvas as above. The additional Command parameter > specifies the command to be generated when the mouse button is pressed. > Key presses are ignored.... > > - Canvas (Parent, Origin, Width, Height, Command, Keypress, Font) > =A0 =A0Construct a canvas as above. The additional Keypress parameter is > optional, and specifies the command to be generated when a key is pressed= ... > > ------------------------------------ > 5.4 Handling user interaction > > A canvas can generate a command when the mouse button is pressed within > its boundaries. This can be used to implement interactive drawing > programs. There are several operations available to let the program > track the mouse WHILE THE BUTTON IS DOWN: > > Start_Point (Canvas) > End_Point (Canvas) > Mouse_Down (Canvas) > Mouse_Moved (Canvas) > ------------------------------------ > > > > > > > > >> 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: > > >> =A0 =A0 =A0function Get_Point return Point_Type is > >> =A0 =A0 =A0 =A0 Here: Point_Type; > >> =A0 =A0 =A0begin > >> =A0 =A0 =A0 =A0 loop > >> =A0 =A0 =A0 =A0 =A0 =A0case Next_Command is > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 when Cmd_Mouse =3D> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit; > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 when Cmd_Quit =3D> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise Program_Aborted; > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 when others =3D> > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0null; > >> =A0 =A0 =A0 =A0 =A0 =A0end case; > >> =A0 =A0 =A0 =A0 end loop; > >> =A0 =A0 =A0 =A0 Here :=3D Start_Point( Main_Canvas ); > >> =A0 =A0 =A0 =A0 return Logical( Here ); > >> =A0 =A0 =A0end Get_Point; > > > What is the type of the following variables: > > Next_Command, Cmd_Mouse, Program_Aborted? > > The type is the user-defined Command_Type (a generic parameter of > JEWL.Windows). I usually use JEWL.Simple_Windows, which defines > Command_Type =3D> Character. > > My canvas is created as: > > =A0 =A0 Cmd_Quit =A0: constant Character :=3D 'Q'; =A0-- for frame > =A0 =A0 Cmd_Mouse : constant Character :=3D 'M'; =A0-- for canvas > =A0 =A0 Cmd_Key =A0 : constant Character :=3D 'K'; =A0-- for canvas > > =A0 =A0 Main_Canvas :=3D Canvas( > =A0 =A0 =A0 =A0Main_Frame, (0,0), 0, 0, Cmd_Mouse, Cmd_Key, ... ); > > > What means Logical? > > It is just a scale conversion from the screen coordinates (pixels) to > the logical coordinates of my application. > > Hint: the JEWL.Windows User Manual contains a lot of code samples. > -- > Manuel Collado -http://lml.ls.fi.upm.es/~mcollado- Tekst uit oorspronkeli= jk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven - Hello Manuel, Implementing your solution works now perfect. Thank you very much for your help.