简体   繁体   中英

What is an event table (wxWidgets)?

What exactly is an event table and what does it do? I am asking regarding wxWidgets but maybe its a general GUI programming concept, so please correct me on that.

To keep it simple, the evend table tells which function to call when which event occurrs.

However, it is an old way of mapping events to functions. It is no longer recommanded because isn't very flexible, and use macro tricks to do its job. Macros themselves are generally not very recommanded in C++.

Unless you must stick to C++03, you should no longer use event tables. Instead, you should use the bind method for New WXWidgets projects in C++11 or later. Bind is more flexible, and don't use macro.

You will find this recommandation in the WXWidgets tutorials, too. You must still be able to read and understand old event tables, though, because many samples haven't been updated for ages.

An event table tells wxWidgets to map events to member functions. It should be defined in a.cpp file.

wxBEGIN_EVENT_TABLE() 

is an example of a macro

In addition to the other answers, I'd like to say that if you're starting learning wxWidgets, you should know that event tables are a legacy way of handling events and that using Bind() is the preferred way of doing it in the new code.

In particular, Bind() is much less "magic", and doesn't use any macros.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM