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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.39.15 with SMTP id l15mr7200361igk.8.1412327060372; Fri, 03 Oct 2014 02:04:20 -0700 (PDT) X-Received: by 10.140.91.181 with SMTP id z50mr567qgd.20.1412327060229; Fri, 03 Oct 2014 02:04:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!uq10no3096634igb.0!news-out.google.com!q8ni41qal.1!nntp.google.com!dc16no389252qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 3 Oct 2014 02:04:20 -0700 (PDT) In-Reply-To: <180c6d86-8d9c-456a-9f30-8f8a679d424c@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=86.160.220.130; posting-account=28F2IwkAAACL1Z5nRC-dE7zuvWdbWC7P NNTP-Posting-Host: 86.160.220.130 References: <993f47a9-a666-43b2-a5d8-c84fe0b22142@googlegroups.com> <298d6277-e6f7-49c7-80d9-748565f87997@googlegroups.com> <217cd7f4-58ac-43c5-965a-64d9252b0474@googlegroups.com> <5ca5a27d-9338-4b20-97d9-62ce7c952898@googlegroups.com> <180c6d86-8d9c-456a-9f30-8f8a679d424c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3b458fe2-6455-4c09-a9c7-ec3616db1cbf@googlegroups.com> Subject: Re: Gnoga - The GNU Omnificent GUI for Ada From: tonyg Injection-Date: Fri, 03 Oct 2014 09:04:20 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:22026 Date: 2014-10-03T02:04:20-07:00 List-Id: On Friday, 3 October 2014 03:28:49 UTC+1, David Botton wrote: > > If I create five buttons and attach the same on click handler, how do I identify the button clicked to the code inside the handler? > > > > There are many ways to do it, here is a simple way (notice the use of dynamic controls, views will deallocate them when they are finalized). When you create each button, give it an ID. e.g. > > > > declare > > My_Button : Button_Access; > > begin > > My_Button := new Button_Type; > > My_Button.Create (My_View, "Click Me 1", ID="b1"); > > My_Button.On_Click_Handler (My_Click'Access); > > > > My_Button := new Button_Type; > > My_Button.Create (My_View, "Click Me 2", ID="b2"); > > My_Button.On_Click_Handler (My_Click'Access); > > end; > > > > procedure My_Click (Object : Base_Type'Class) is > > begin > > if Object.ID = "b1" then > > Gnoga.Log ("Clicked Button 1"); > > if Object.ID = "b2" then > > Gnoga.Log ("Click Button 2"); > > end if; > > end My_Click; Thanks David, thats really helpful :)