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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a0c:e9c4:: with SMTP id q4mr14512307qvo.61.1572708463841; Sat, 02 Nov 2019 08:27:43 -0700 (PDT) X-Received: by 2002:a9d:4042:: with SMTP id o2mr81772oti.22.1572708463543; Sat, 02 Nov 2019 08:27:43 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!j16no3462882qtl.0!news-out.google.com!p4ni375qtu.1!nntp.google.com!j16no3462873qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 2 Nov 2019 08:27:43 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:a03f:e3e9:4d00:1260:4bff:fe89:deb2; posting-account=kTRirAoAAACnF_wtAOSamxYBSVvmJuCa NNTP-Posting-Host: 2a02:a03f:e3e9:4d00:1260:4bff:fe89:deb2 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <24540edc-eb1d-40d4-99ab-7ff54c5e61d6@googlegroups.com> Subject: Re: gtkada evenhandler on_procedure method , how to access children of topwindow in the eventhandler From: Alain De Vos Injection-Date: Sat, 02 Nov 2019 15:27:43 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57443 Date: 2019-11-02T08:27:43-07:00 List-Id: On Saturday, November 2, 2019 at 11:22:49 AM UTC+1, Alain De Vos wrote: > I have a window with obe button and one label and want to change the text on the label when the button is pressed in the eventhandler, I pass the top window. > > procedure hello is > Top : Gtk.Window.Gtk_Window; > Button : Gtk_Button; > Label : Gtk_Label; > VBox : Gtk_Box; > procedure Create_Window is > begin > Gtk.Window.Gtk_New > (Window => Top, > The_Type => Gtk.Enums.Window_Toplevel); > Gtk.Window.Set_Title (Window => Top, Title => "Hello from ADA"); > Gtk_New(Button); > Button.On_Clicked (Call => On_Button_Click'Access, > Slot => Top); > Gtk_New(Label); > Gtk_New_Vbox(VBox); > Add (VBox,Button); > Add (VBox,Label); > Add (Top,VBox); > Gtk.Window.Show_All (Top); > end Create_Window; > begin > Gtk.Main.Init; > Create_Window; > Gtk.Main.Main; > end hello; > > I pass the topwindow to the eventhandler(slot). > In the eventhandler I need go from the Top to the Vbox to the Label and set the text on the label ... button pressed. I probably need to set a property in the main and query it in the handler and cast the correct type ... > {The label is not directly visible in the handler ...} > > package body buttonhandler is > procedure On_Button_Click (Top : access Glib.Object.GObject_Record'Class) is > begin > Put_line ("Hallo"); > -- I need to go from Top to Vbox to Label and set text ... ???? > end On_Button_Click; > end buttonhandler; In the main program I can have, MyVBox.Button.On_Clicked (Call => On_Button_Click'Access, Slot => Top); MyVBox.Button.On_Clicked (Call => On_Button_Click'Access, Slot => MyVBox); with Top : Gtk.Window.Gtk_Window; MyVBox : MyVBoxT; Both work fine, In handler i can have, procedure On_Button_Click (Top : access Glib.Object.GObject_Record'Class), this works fine, But when i try : procedure On_Button_Click (MyVBox : access Gtk_Button_Record'Class) the error received is : hello.adb:33:56: expected type "Cb_GObject_Void" defined at gtk-button.ads:445 hello.adb:33:56: found type access to procedure "On_Button_Click" defined at... In the docs procedure On_Clicked is defined as : (Self : not null access Gtk_Button_Record; Call : Cb_Gtk_Button_Void; After : Boolean := False);