From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Gavin McCord Newsgroups: comp.lang.ada Subject: Re: On_Button_Press_Event in Text_View Date: Wed, 14 Aug 2024 11:42:14 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 14 Aug 2024 13:42:14 +0200 (CEST) Injection-Info: dont-email.me; posting-host="034404137cba17d7132df0007dfa49e2"; logging-data="472567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yfLm/r5rc0Wgp7mEbHho/wlIQtUefIUgrZOSATIVTiQ==" User-Agent: Pan/0.149 (Bellevue; 4c157ba git@gitlab.gnome.org:GNOME/pan.git) Cancel-Lock: sha1:sBIQ3EOecawFBW+3tZRY3WnuO2M= Xref: news.eternal-september.org comp.lang.ada:66303 List-Id: On Tue, 13 Aug 2024 22:29:59 +0200, Dmitry A. Kazakov wrote: > On 2024-08-13 13:37, Gavin McCord wrote: > >> 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). > > Something like this: > > package Event_Handlers is > new Gtk.Handlers.User_Return_Callback > ( GObject_Record, > Boolean, User_Data_Type > ); > > > function On_Button_Press > ( Object : access GObject_Record'Class; > Event : Gdk_Event; Data : User_Data_Type > ) return Boolean; > > > View.Set_Events (View.Get_Events or Button_Press_Mask); > Event_Handlers.Connect ( View, > "button-press-event", > Event_Handlers.To_Marshaller (On_Button_Press'Access), > Data > ); Thank you. That allows me to pass a record of the buffer. There's only one other thing. If I try to check the Event I get another error, such as function On_Button_Press [skipped lines] if Event.The_Type = Gdk_2button_Press then Put_Line ("double-click"); end if; Attempting to compile that gives me error: cannot reference discriminant of unchecked union Gavin McCord