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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.162.162 with SMTP id yb2mr2537177pab.39.1412303328282; Thu, 02 Oct 2014 19:28:48 -0700 (PDT) X-Received: by 10.140.100.162 with SMTP id s31mr3341qge.17.1412303327935; Thu, 02 Oct 2014 19:28:47 -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!h18no954714igc.0!news-out.google.com!q8ni41qal.1!nntp.google.com!dc16no375780qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 2 Oct 2014 19:28:47 -0700 (PDT) In-Reply-To: <5ca5a27d-9338-4b20-97d9-62ce7c952898@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.176.73.77; posting-account=yiWntAoAAAC1KqC_shmxJYv07B9l6LNU NNTP-Posting-Host: 66.176.73.77 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <180c6d86-8d9c-456a-9f30-8f8a679d424c@googlegroups.com> Subject: Re: Gnoga - The GNU Omnificent GUI for Ada From: David Botton Injection-Date: Fri, 03 Oct 2014 02:28:47 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:22008 Date: 2014-10-02T19:28:47-07:00 List-Id: > 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;