home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:19977 comp.std.c++:2129
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!elroy.jpl.nasa.gov!usc!news.cerf.net!nic.cerf.net!hlf
- From: hlf@nic.cerf.net (Howard Ferguson)
- Newsgroups: comp.lang.c++,comp.std.c++
- Subject: Re: Callbacks -- suggested approaches??
- Date: 26 Jan 1993 21:10:08 GMT
- Organization: CERFnet Dial n' CERF Customer Group
- Lines: 49
- Message-ID: <1k49bgINNo63@news.cerf.net>
- References: <DAVIDM.93Jan25171343@consilium.com> <1k41efINN2oj@darkstar.UCSC.EDU>
- NNTP-Posting-Host: nic.cerf.net
-
- In article <1k41efINN2oj@darkstar.UCSC.EDU> spencer@cats.ucsc.edu (Michael Spencer) writes:
- >
- >davidm@consilium.com (David S. Masterson) writes:
- >
- >>I'm looking for suggestions on how to handle callback functions in C++ that
- >>will be more standard than the one we're currently using.
- >
- >Would the following approach be helpful. If so, drop me a message.
- >
- >
- > WIDGET CALLBACKS
- >
- >Widgets which use callbacks are similarly easy. XSimple widgets attach
- >their own callback and pass to it a reference to a coder written
- >Procedure. The callback calls the Procedure and passes to it a
- >Choice object which contains the data needed to respond to the event.
- >For example, to activate a popup dialog widget:
- >
- > PopupYesno (parent, "Do it ?", YesnoProc); // evoke popup
- >
- > void YesnoProc (Choice chose) // coder written to handle event
- > {
- > if (chose.flag)
- > // do something
- > }
- > else
- > // do something else
- > }
- >
- >The coder written YesnoProc() defines what occurs based on the
- >user's election. Choice is an object (declared in XUTILS.H) which
- >will hold any information generated by any callback or event handler.
- >
- >BUT, the coder need not become involved in the sordid details of
- >adding the callback to the widget or extracting the relevant
- >information from the returned callback struct. That is done
- >automatically and the relevant information is passed via the
- >Choice data members.
-
- Yes but the coder does have to get involved in the sordid details
- of the prototype of the YesnoProc. Ther type of the function being
- passed in has to be considered. In good old C the function would
- be automatically cast to whatever form it was stored in.
-
- hlf
-
-
-
-
-