Boost logo

Boost :

From: Bohdan (gejrlaug_at_[hidden])
Date: 2003-08-11 14:16:16


"John Torjo" <john.lists_at_[hidden]> wrote in message
news:003c01c35fea$dbb983a0$0a011bac_at_PEOPLEFIRST...
> >
> > AFAIK, some gui toolkits use not event, but callback system.
> > IMHO it is more evective. Definitely it should be discussed
> > carefully.
> >
> Aren't we talking about the same thing? ;)

Not exactly.

------------- Callbacks ------------------
button b;
b.on_click_callback = &do_button_down; // or: b.on_click_callback.connect(
&my_func );

-------------- Events --------------------

class MyButton : public button
{
private:
    void dispatch_event( Event & event )
    {
         switch( event.ID )
         {
         ....
         case EVENT_BUTTON_DOWN:
                do_button_down( ... ); break;
         ...
         defautl:
                default_handler( ... );
         }
    }
};
---------------------------------------------------

    Sure you can wrap event-interface to work with callbacks and vice-versa
or even user mixed approach.
  Have nothing against your ideas :) just want to note that there are
can be 'native' gui libs that are not using event-objects at all and
that event mapping/dispatch probelm is platform specific.
  The question is which interface (callback or events) is more comfortable
for user and which one is more effective. IMHO, mapping proposed by
you should be deeply inside library and user interface should work with
callbacks only.

> In response to an event, you call an event callback.
> That's what my example does - it's obfuscated indeed, but that's
> because I had to tweak it to work with VC6.

regards,
bohdan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk