Domingo Alvarez Duarte wrote:
> I'm experimenting with dao http://daovm.net/ and his author did an
> amazing job creating a automated tool that can create bindings to almost
> all fltk 1.3 including deriving fltk classes, but for it to work with
> callbacks easily he needs to make "void do_callback(Fl_Widget* o,void*
> arg=0)" a virtual function.
>
> I propose to make this modification on the official FLTK sources.
>
> Changes:
> from: void do_callback(Fl_Widget* o,void* arg=0);
> to: virtual void do_callback(Fl_Widget* o,void* arg=0);
>
> With this modification examples like this works:
>
> ------
> load DaoFLTK;
>
> class Button1 : Fl_Button
> {
> sub do_callback( w : Fl_Widget, a : cdata ){
> io.write( '\07' );
> io.flush();
> }
> }
> class Button2 : Fl_Button
> {
> sub do_callback( w : Fl_Widget, a : cdata ){
> std.exit(0);
> }
> }
>
> window = Fl_Window(320,65);
> b1 = Button1(20, 20, 80, 25, '&Beep');
> b2 = Fl_Button(120,20, 80, 25, '&no op');
> b3 = Button2(220,20, 80, 25, 'E&xit');
> window.end();
> window.show();
> Fl.run();
> ------

Looking at the responses I'll try clarify some issues, first we don't 
need to make all three do_calback virtual because the other are an 
indirection to the proposed one.

The way fltk manages callback without a need to derive a class is a good 
one, but sometimes like on this case deriving is helpfull too.

Ans as said here:

 >Well, IMHO callbacks are rarely called (mostly by user interaction,
 >i.e. clicking a button - as opposed to handle(), i.e. moving the
 >mouse), and thus I don't think that *this* would be a problem.

For an interpreted language is better to hook no so frequently called 
methods like handle for performance reasons.

I don't want to slow things down too.

And when proposing this based on the problem faced with the "dao" 
language I was thinking that this could be usefull to others too.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to