If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
-
Tapsa
- Earned some good credits

- Posts: 147
- Joined: Tue Dec 06, 2011 5:52 pm
- Location: Helsinki
Post
by Tapsa » Mon Nov 07, 2016 8:32 am
How can I use this when I have no need for the event variable?
Code: Select all
void wxEvtHandler::Bind(const EventTag &eventType, Functor functor)
The only way I have achieved this is by using lambdas.
How do I simply put any normal member function as the second argument?
-
catalin
- Moderator

- Posts: 1598
- Joined: Wed Nov 12, 2008 7:23 am
- Location: Romania
Post
by catalin » Mon Nov 07, 2016 11:44 am
Use a lambda to call your function that does not need the event variable. Otherwise you can only bind to a function that takes an event as parameter (which AFAIR is needed by a lambda too, isn't it?).
A "normal member function" is not a functor. You can read more about it at
Dynamic Event Handling, search for "bind to an arbitrary functor".
-
Tapsa
- Earned some good credits

- Posts: 147
- Joined: Tue Dec 06, 2011 5:52 pm
- Location: Helsinki
Post
by Tapsa » Mon Nov 07, 2016 2:08 pm
Ty. So not really doable in the way I thought.
-
Manolo
- Can't get richer than this

- Posts: 726
- Joined: Mon Apr 30, 2012 11:07 pm
Post
by Manolo » Mon Nov 07, 2016 3:57 pm
Uh? Did I understand you well? Look at this sample in the docs:
Code: Select all
void HandleExit( wxCommandEvent & )
{
// Do something useful
}
MyFrame::MyFrame()
{
Bind( wxEVT_COMMAND_MENU_SELECTED, &HandleExit, wxID_EXIT );
There's no lamba there. There's no wxEventHandler-derived function.
If you don't use the event variable you can avoid it at your handler:
Code: Select all
void HandleExit(wxCommandEvent& WXUNUSED(evnt))
-
catalin
- Moderator

- Posts: 1598
- Joined: Wed Nov 12, 2008 7:23 am
- Location: Romania
Post
by catalin » Mon Nov 07, 2016 4:05 pm
Manolo wrote:Uh? Did I understand you well? Look at this sample in the docs:
Code: Select all
void HandleExit( wxCommandEvent & )
{
// Do something useful
}
MyFrame::MyFrame()
{
Bind( wxEVT_COMMAND_MENU_SELECTED, &HandleExit, wxID_EXIT );
There's no lamba there. There's no wxEventHandler-derived function.
I don't think anybody said anything about "wxEventHandler-derived function".