FLTK logo

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 | SVN ⇄ GIT ]

STR #214

Application:FLTK Library
Status:1 - Closed w/Resolution
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.
Version:1.4-feature
Created By:rainer.koecher.ok-automation
Assigned To:matt
Fix Version:1.4.0
Fix Commit:10d9010ed9a7624bebebcb0f86fc86d362672027
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 rainer.koecher.ok-automation
01:53 Nov 19, 2003
hello,

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);
  }
  public:
    Example(){
    //initialize the Window
    }
}

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

class Example{
  //define a callback object which operator() will be called.
  callback button_callback;
  public:
    Example(){
    //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.  
 
#7 matt
06:29 Sep 29, 2023
Fixed in Git repository.

We now have macros that solve this issue even for very early version of C++.

See FL_FUNCTION_CALLBACK, FL_METHOD_CALLBACK, and FL_INLINE_CALLBACK in fl_callback_macros.h
 
     

Return to Bugs & Features ]

 
 

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