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: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!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: Sat, 23 Oct 2010 00:15:54 +0200 Organization: Universitat de Valencia Message-ID: References: <057188e8-a7c9-4aeb-968c-ccdf720bd0fc@t20g2000yqa.googlegroups.com> <3bdec7d9-3dc6-44f1-be1b-8aa8dd539360@k22g2000yqh.googlegroups.com> NNTP-Posting-Host: 83.46.237.8 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: peque.uv.es 1287785882 22640 83.46.237.8 (22 Oct 2010 22:18:02 GMT) X-Complaints-To: newsmanager@uv.es NNTP-Posting-Date: Fri, 22 Oct 2010 22:18:02 +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: <3bdec7d9-3dc6-44f1-be1b-8aa8dd539360@k22g2000yqh.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:14688 Date: 2010-10-23T00:15:54+02:00 List-Id: El 22/10/2010 15:55, tolkamp escribi�: [sinipped] >>> My_Frame := Frame (1200, 500, "", 0); >>> My_Canvas := Canvas (Frame, (850,10), 300, 300); This declares a non-interactive canvas. >>> loop >>> My_Mouse_Position := 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) Construct a canvas... MOUSE CLICKS AND KEY PRESSES ARE BOTH IGNORED... - Canvas (Parent, Origin, Width, Height, Command, Font) Construct 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) Construct 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: >> >> 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; >> > > 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 => Character. My canvas is created as: Cmd_Quit : constant Character := 'Q'; -- for frame Cmd_Mouse : constant Character := 'M'; -- for canvas Cmd_Key : constant Character := 'K'; -- for canvas Main_Canvas := Canvas( Main_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