X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5833988cb7a092f9976c1fb2320d4013f825400a..d3fa4bc22e84e3ca4d88cc1772f2d414140a1017:/interface/wx/event.h diff --git a/interface/wx/event.h b/interface/wx/event.h index b9cc77bfe6..74655ab7c1 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -525,7 +525,9 @@ public: @param x1 The (optional) first parameter to pass to the method. @param x2 The (optional) second parameter to pass to the method. - Note that currently only up to 2 arguments can be passed. + Note that currently only up to 2 arguments can be passed. For more + complicated needs, you can use the CallAfter(const T& fn) overload + that can call any functor. @note This method is not available with Visual C++ before version 8 (Visual Studio 2005) as earlier versions of the compiler don't @@ -536,6 +538,39 @@ public: template void CallAfter(void (T::*method)(T1, ...), T1 x1, ...); + /** + Asynchronously call the given functor. + + Calling this function on an object schedules an asynchronous call to + the functor specified as CallAfter() argument at a (slightly) later + time. This is useful when processing some events as certain actions + typically can't be performed inside their handlers, e.g. you shouldn't + show a modal dialog from a mouse click event handler as this would + break the mouse capture state -- but you can call a function showing + this message dialog after the current event handler completes. + + Notice that it is safe to use CallAfter() from other, non-GUI, + threads, but that the method will be always called in the main, GUI, + thread context. + + This overload is particularly useful in combination with C++11 lambdas: + @code + wxGetApp().CallAfter([]{ + wxBell(); + }); + @endcode + + @param functor The functor to call. + + @note This method is not available with Visual C++ before version 8 + (Visual Studio 2005) as earlier versions of the compiler don't + have the required support for C++ templates to implement it. + + @since 2.9.6 + */ + template + void CallAfter(const T& functor); + /** Processes an event, searching event tables and calling zero or more suitable event handler function(s).