From 8072481f86e6d424bcd2d583ea6070439f99d7ff Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Aug 2016 14:01:52 +0200 Subject: [PATCH] Show using C++11 lambda in the "Hello world" example This is so useful, that it should be mentioned even on this introductory page. --- docs/doxygen/overviews/helloworld.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/doxygen/overviews/helloworld.h b/docs/doxygen/overviews/helloworld.h index 2c60c78c5b..8b2fefa5f7 100644 --- a/docs/doxygen/overviews/helloworld.h +++ b/docs/doxygen/overviews/helloworld.h @@ -209,6 +209,17 @@ void MyFrame::OnHello(wxCommandEvent& event) } @endcode +@note In C++11 programs, it can be convenient to use unnamed lambdas instead of + functions for event handlers, especially when handling events from the + controls as this allows to keep the code creating the control and handling + its event together in the same place. Here, for example, we could replace + the wxID_EXIT handler with just + +@code + Bind(wxEVT_MENU, [=](wxCommandEvent&) { Close(true); }, wxID_EXIT); +@endcode + + Here is the entire program that can be copied and pasted: @code