comp.lang.ada
 help / color / mirror / Atom feed
* On_Button_Press_Event in Text_View
@ 2024-08-13 11:37 Gavin McCord
  2024-08-13 20:29 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 5+ messages in thread
From: Gavin McCord @ 2024-08-13 11:37 UTC (permalink / raw)


Using gtkada (gtk3), is it possible to use a custom handler to
deal with a button-press-event (or other events if necessary)
inside a widget such as a Text_View?

For example I create a Text_View with buffer. To process a
button-press within that view I have this code in my main
procedure:

  The_View.On_Button_Press_Event (Press_CB'Access);
  The_View.Set_Events (The_View.Get_Events or Button_Press_Mask);

The callback looks like this:

  function Press_CB (Self  : access Gtk_Widget_Record'Class;
                     Event : Gdk_Event_Button)
                     return Boolean is
   begin
      Put_Line ("Mouse click in text view");
      return True;
   end Press_CB;

So far, so good.

But I'd like to pass additional data to the callback,
without using global variables/records if it can be
avoided.

I have a custom handler used when I update the Text_Buffer:

 Button_Callback.Connect
   (Update_Button, "clicked", Update_Clicked'Access,
    Buffer_To_Pass);

That works fine so I was imagining something similar might
be possible, but I've run through various permuations of
records and access types but not yet got a working callback.

Any help gratefully received (I can post the full code if
that's useful).

Kind regards,

Gavin McCord

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-14 14:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-13 11:37 On_Button_Press_Event in Text_View Gavin McCord
2024-08-13 20:29 ` Dmitry A. Kazakov
2024-08-14 11:42   ` Gavin McCord
2024-08-14 12:03     ` Dmitry A. Kazakov
2024-08-14 14:34       ` Gavin McCord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox