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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Mouse Clicks in a Drawing Area Date: Tue, 4 Feb 2014 11:44:00 +0100 Organization: cbb software GmbH Message-ID: <17s5lkm60lq92.a7lidua6gycy$.dlg@40tude.net> References: <52f08d46$0$9122$703f8584@news.kpn.nl> <52f0bc8a$0$31367$703f8584@news.kpn.nl> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: I5Na6+WsEzT8WoegI0VZTA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 3046 Xref: number.nntp.dca.giganews.com comp.lang.ada:184648 Date: 2014-02-04T11:44:00+01:00 List-Id: On Tue, 4 Feb 2014 11:08:30 +0100, ldries46 wrote: > I now het changed the Add_Events into Set_Events (within the first code > listing but the result is the same, nothing happens. > I had done it that way before but > > http://askubuntu.com/questions/157290/how-to-draw-on-mouse-click-in-gtk-drawingarea-using-pygi > > suggested the add_events routine. That code is now > > Set_Events(Sudoku_Area, BUTTON_PRESS_MASK); > CR := Create(Get_Window (Sudoku_Area)); > Event_Cb.Connect (Sudoku_Area, "draw", > Event_Cb.To_Marshaller > (On_Area_Draw'Unrestricted_Access)); > Event_Cb.Connect (Sudoku_Area, "button_press_event", > Event_Cb.To_Marshaller > (On_Button_Press'Unrestricted_Access)); > > The problem stays the same as. > Typically for mouse tracking you would do: Sudoku_Area.Set_Can_Focus (True); Sudoku_Area.Set_Events ( Exposure_Mask or Leave_Notify_Mask or Button_Press_Mask or Button_Release_Mask or Pointer_Motion_Mask or Pointer_Motion_Hint_Mask ); > Just for extra information the code od On_Button_Press: > > function On_Button_Press (Object : access Gtk_Drawing_Area_Record'Class; > event : Gdk_Event) return boolean is > pragma Unreferenced (Object); > begin > ev := event.Button; -- line where the breakpoint is invoked > nb := ev.Button; > if nb = 1 then > x := ev.X; > y := ev.Y; > end if; > return nb = 1; > end On_Button_Press; You would use Get_Button to determine which mouse button was pressed. P.S. It is not a good idea to use global variables as you do. For this reason Connect operations to attach callbacks have very limited use. In most cases you should instantiate User_Callback or User_Return_Callback to be able to pass an additional parameter to the handler. P.P.S. You should not use debugger with GTK. It works very rarely if at all. Do tracing instead. And you must always handle all exceptions within signal handlers. Propagation out of a handler will certainly corrupt stack and crush the program. Use Glib.Messages it is a great help. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de