Wt
4.11.0
|
Support for event handling using signals and slots. More...
Classes | |
class | Wt::SignalBase |
Abstract base class of a signal. More... | |
class | Wt::EventSignalBase |
Abstract base class of an event signal. More... | |
class | Wt::WMouseEvent |
A class providing details for a mouse event. More... | |
class | Wt::WKeyEvent |
A class providing details for a keyboard event. More... | |
class | Wt::WDropEvent |
A class providing details for a drop event. More... | |
class | Wt::WScrollEvent |
A class providing details for a scroll event. More... | |
class | Wt::WTouchEvent |
A class providing details for a touch event. More... | |
class | Wt::WGestureEvent |
A class providing details for a gesture event. More... | |
class | Wt::JSignal< A > |
A signal to relay JavaScript to C++ calls. More... | |
class | Wt::JSlot |
A slot that is only implemented in client side JavaScript code. More... | |
class | Wt::WObject |
A base class for objects that participate in the signal/slot system. More... | |
class | Wt::Signal< A > |
A signal that propagates events to listeners. More... | |
class | Wt::EventSignal< E > |
A signal that conveys user-interface events. More... | |
Support for event handling using signals and slots.
To respond to user-interactivity events, or in general to communicate events from one widget to any other, Wt uses a signal/slot system.
A slot is any method of any descendant of WObject. To connect a signal with a slot, the only requirement is that the method signature of the slot must be compatible with the signal definition. In this way every method may be used as a slot, and it is not necessary to explicitly indicate a particular method to be a slot (as is needed in Qt), by putting them in a special section. Nevertheless, you may still do that if you wish to emphasize that these functions can be used as slots, or, if you have done extra work to optimize the implementation of these methods as client-side JavaScript code (see below).
A signal may be created by adding a Signal<X, ...> object to your class. You may specify up to 6 arguments which may be of arbitrary types that are Copyable, that may be passed through the signal to connected slots.
The library defines several user-event signals on various widgets, and it is easy and convenient to add signals and slots to widget classes to communicate events and trigger callbacks.
Event signals (EventSignal<E>) are signals that may be triggered internally by the library to respond to user interactivity events. The abstract base classes WInteractWidget and WFormWidget define most of these event signals. To react to one of these events, the programmer connects a self-defined or already existing slot to such a signal.
To connect a signal from multiple senders to a single slot, we recommend the use of std::bind() to identify the sender (or otherwise the intention) of the signal.
Usage example:
Enumeration for key codes.
These are key codes that identify a key on a keyboard. All keys listed here can be identified across all browsers and (Western) keyboards. A Key is returned by WKeyEvent::key(). If you want to identify a character, you should use the WKeyEvent::charCode() method instead.
|
strong |