STR #214

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]

Return to Bugs & Features | Post Text | Post File | Prev | Next ]

STR #214

Application:FLTK Library
Status:4 - Pending
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:3 - Applies to all machines and operating systems
Subsystem:Core Library
Summary:function objects for callbacks.
Created By:rainer.koecher.ok-automation
Assigned To:matt
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files

Trouble Report Comments:

Post Text ]
Name/Time/Date Text top right image
#1 rainer.koecher.ok-automation
01:53 Nov 19, 2003

I did a little work for testing with fltk. The toolkit looks very professional. But I'm missing one feature: I'd like to use function objects for callbacks instead of static member functions of classes. I think if you want to implement a object oriented system it's not good to have static member functions.

Here is a little example of what i'm meaning.

now callbacks work in that way:
class Example{
  void callback_function_i(FL_Button *bt, void *v)
    // do something useful.

  //v would be a pointer to "this"
  static void callback_function(FL_Button *bt, void *v)
    v->callback_function_i(bt, v);
    //initialize the Window

i wold like to do this in that way:
class callback{
void operator()(Fl_Button *bt, void *v)
  //  do something useful.

class Example{
  //define a callback object which operator() will be called.
  callback button_callback;
    //initialize the Window
#2 mike
21:16 Mar 10, 2004
There are some enhancements along these lines available on the bazaar/links page. Currently they require "advanced" C++ features which are not universally available, but they may be added in the future.  
#3 matt
14:50 Apr 22, 2008
This STR stands as a reminder for signaling and member callbacks  
#4 matt
16:40 Jan 14, 2023
This can not be solved as long as we insist on C++98. C++11 introduces lambdas with captures that solve this very easily.  
bottom left image   bottom right image

Return to Bugs & Features | Post Text | Post File ]


Comments are owned by the poster. All other content is copyright 1998-2023 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to ''.