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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,eafb0c0f59b030c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!f16g2000cwb.googlegroups.com!not-for-mail From: "Lucretia" Newsgroups: comp.lang.ada Subject: Re: Event mechanisms for GUI's Date: 19 Oct 2006 07:22:09 -0700 Organization: http://groups.google.com Message-ID: <1161267729.431982.31510@f16g2000cwb.googlegroups.com> References: <3egSg.208528$1i1.141541@attbi_s72> <1159338085.495558.286500@i42g2000cwa.googlegroups.com> <7s2dnaT_9fw5nobYnZ2dnUVZ_tOdnZ2d@megapath.net> <_AHSg.210879$1i1.191702@attbi_s72> <1160853954.468627.128210@m7g2000cwm.googlegroups.com> <1160879371.648453.23540@h48g2000cwc.googlegroups.com> NNTP-Posting-Host: 62.56.72.136 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1161267734 26914 127.0.0.1 (19 Oct 2006 14:22:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 19 Oct 2006 14:22:14 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.5) Gecko/20060903 Firefox/1.5.0.5,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: f16g2000cwb.googlegroups.com; posting-host=62.56.72.136; posting-account=G-J9fgwAAADgpzBiEyy5tO4f8MX5fbpw Xref: g2news2.google.com comp.lang.ada:7040 Date: 2006-10-19T07:22:09-07:00 List-Id: On Oct 16, 5:11 am, "Jeffrey R. Carter" wrote: > Lucretia wrote: > > > So, on creation you specify which events you want via some sort of > > bitmask?I would think there would be a default set, to which you could add or > subtract events or sets of events, as well as specifying a complete set > of events. The only way I can see of doing this (unless you want to supply some code to illustrate) is by providing the listener idiom and separating each listener "handler" into a separate interfaces (Ada 2005) and then providing a Set_Events_Mask on the component which goes through the bit mask and checks if there are interfaces set for the particular events: package Button_Up_Listeners is type Button_Up_Listener is interface; procedure Button_Up(Component : in Button; Event : in Button_Event); end Button_Up_Listeners; package Button_Down_Listeners is type Button_Down_Listener is interface; procedure Button_Down(Component : in Button; Event : in Button_Event); end Button_Down_Listeners; package Buttons is type Button_Events_Mask is (Up, Down, Double_Click, ...); for Button_Events_Mask use ...; Button_Events_Mask_Error : exception; type Button is new Control with private; procedure Set_Button_Up_LIstener(Self : in out Button; Listener : in Button_Up_Listener); procedure Set_Button_Down_LIstener(Self : in out Button; Listener : in Button_Down_Listener); -- This raises Button_Events_Mask_Error procedure Set_Bit_Mask(Self : in out Button; Mask : in Button_Events_Mask); end Buttons; package My_Button_Listeners is type My_Button_Listener is Button_Up_Listener and Button_Down_Listener; ... end My_Button_Listeners; procedure Test_Button is My_Button : Button; begin My_Button.Set_Button_Up_LIstener(My_Button_Listener); My_Button.Set_Bit_Mask(Up or Down); -- raises exception! end Test_Button; But there are problems with this: 1) use of multiple interfaces just to provide 1 "event handler" over the use of 1 listener interface which provides all "event handlers" which are specified as null procedures so that the user can override the ones (s)he is interested in. 2) the user may forget to do the test (the Set_Bit_Mask call). Thanks, Luke.