home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!usc!elroy.jpl.nasa.gov!decwrl!borland.com!pete
- From: pete@genghis.borland.com (Pete Becker)
- Subject: Re: Callbacks - C++ needs an extension?
- Message-ID: <1992Aug29.161356.16729@genghis.borland.com>
- Originator: pete@genghis.borland.com
- Keywords: callback event eventdriven extension
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- References: <1992Aug28.165108.17479@isy.liu.se>
- Date: Sat, 29 Aug 1992 16:13:56 GMT
- Lines: 35
-
- In article <1992Aug28.165108.17479@isy.liu.se> svan@isy.liu.se writes:
- >Hi guys!
- >
- >Maybe some of you have, like me, done some windowprogramming in
- >C++. There are a lot of toolkits to choose from, but whatever
- >you choose, wether it is a C++-package like TNT or a C-package
- >like xview, you'll probably stumble upon the notion of call-
- >backs.
- >
- >Callbacks are essencially a functionpointer you deliver to
- >the windowing toolkit when creating a widget, for instance
- >a button. This function is then supposed to be called when
- >the user have taken some action, like pressing the button.
- >
- >Their existance is motified by the nature of event-driven
- >programming and that it is most unpractical to have to edit
- >sourcecode in the toolkit when you want a special function in
- >your source to be called.
- >
- >Most often a button is connected to some sort of other
- >object, like a window, and it is most often the window that
- >knows how to response when the button is pressed.
- >
- >The problem is that it seems impossible in C++ to implement
- >a callback strategy which calls this window-object directly...
- >
-
- The problem is not in C++ but in libraries that constrain callback
- functions to look like ordinary C functions. Such libraries are old
- technology, and making newer techniques work will always require a certain
- amount of work.
- The most straightforward solution is to work with the library and
- provide a callback function that examines the message being sent and forwards
- it to the appropriate recipient.
- -- Pete
-