From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GtkAda callback and event Date: Fri, 10 Sep 2021 08:38:02 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <6133e791$0$6461$426a74cc@news.free.fr> <6134cb26$0$3697$426a74cc@news.free.fr> <6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr> <6134e03d$0$3372$426a74cc@news.free.fr> <61352d42$0$3749$426a74cc@news.free.fr> <944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com> <6139be6f$0$12704$426a74cc@news.free.fr> <757da468-7b58-43c2-95e6-917b3212f7b2n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="22297"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62686 List-Id: On 2021-09-09 23:01, Jere wrote: > Okie dokie! After reading this chain I took a look at the GtkAda manual and > saw that they had separate high level events for things like button clicks and > such and that they used access to 'Class types so I was hoping that meant > for the OP that they could, for example do something like: > > type My_Button is new Gtk.Whatever_Path.Button_Type with record > User_Data : User_Data_Type; > end record; type My_Button is new Get_Button_Record with record User_Data : User_Data_Type; end record; > procedure On_Button_Click(Self : access to Button_Type'Class) is > A_Button : My_Button renames My_Button(Self.all); -- forget if this is allowed or not > begin > -- use A_Button.User_Data.??? > end On_Button_Click; > > and attach that as the handler. But based on what you said it sounds like this is not > actually an option. (And of course the OP isn't using buttons, but just an example). This works perfectly well in GtkAda. Unfortunately is not what is needed in most cases. User data is a property of the event not of the button. E.g. consider a button to save file. The user data would be some Ada object responsible for dealing with the file. What about other buttons? What about life-times of buttons? User data usually have a longer life span etc. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de