First, don't use Connect()
which was superseded by Bind() which is better in every way.
Second, both static (using event tables) and dynamic (using Bind()
) methods of handling events work and you can use whichever you prefer. Personally, I recommend using Bind()
because
- It is much more flexible: can be used to connect the event on one object to any other object or even a free function or, in C++11, a lambda.
- It is safer and catches most common errors such as using wrong event handler signature at compile time.
- It is "dynamic", i.e. you can connect and disconnect the handler at any time.
The main advantages of the event tables are that
- They are slightly shorter, especially in pre 3.0 versions.
- They are much more common in documentation, examples, tutorials, ... just because they had a 15 year head start on
Bind()
.
However they are clumsier to use because they require subclassing (deriving a new class from) an object in order to handle non-command events in it and they don't detect all errors at compile-time allowing you to write code that compiles fine but crashes at run-time.