Wt
4.11.0
|
A signal that conveys user-interface events. More...
#include <Wt/WSignal.h>
Public Member Functions | |
virtual bool | isConnected () const override |
Returns whether the signal is connected. | |
template<class F > | |
Wt::Signals::connection | connect (F function) |
Connects to a function. | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)()) |
Connects a slot that takes no arguments. | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(E)) |
Connects a slot that takes one argument. | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(const E &)) |
Connects a slot that takes a 'const argument&'. | |
void | connect (const std::string &function) |
Connects a JavaScript function. | |
void | connect (JSlot &slot) |
Connects a slot that is specified as JavaScript only. | |
void | emit (E e=NoClass()) const |
Emits the signal. | |
void | operator() (E e) const |
Emits the signal. | |
virtual Wt::Signals::connection | connect (WObject *target, WObject::Method method) override |
Connects to a slot. | |
Public Member Functions inherited from Wt::EventSignalBase | |
const char * | name () const |
Returns the event name. | |
void | disconnect (JSlot &slot) |
Disconnects a JSlot. | |
void | preventDefaultAction (bool prevent=true) |
Prevents the default browser action. | |
bool | defaultActionPrevented () const |
Returns whether the default browser action is prevented. | |
void | preventPropagation (bool prevent=true) |
Prevents event propagation. | |
bool | propagationPrevented () const |
Returns whether event propagation is prevented. | |
virtual Wt::Signals::connection | connect (WObject *target, WObject::Method method)=0 |
Connects to a slot. | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)()) |
Connects to a slot. | |
Public Member Functions inherited from Wt::SignalBase | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)()) |
Connects to a slot. | |
A signal that conveys user-interface events.
An EventSignal is a special Signal that may be triggered by user interface events such as a mouse click, key press, or focus change. They are made available through the library in widgets like WInteractWidget, and should not be instantiated directly.
In addition to the behaviour of Signal, they are capable of both executing client-side and server-side slot code. They may learn JavaScript from C++ code, through stateless slot learning, when connected to a slot that has a stateless implementation, using WObject::implementStateless(). Or they may be connected to a JSlot which provides manual JavaScript code.
The typically relay UI event details, using event details objects like WKeyEvent or WMouseEvent.
Connects a JavaScript function.
This will provide a client-side connection between the event and a JavaScript function. The argument must be a JavaScript function which optionally accepts two arguments (object and the event):
Unlike a JSlot, there is no automatic connection management: the connection cannot be removed. If you need automatic connection management, you should use connect(JSlot&) instead.
Wt::Signals::connection Wt::EventSignal< E >::connect | ( | F | function | ) |
Connects to a function.
This variant of the overloaded connect() method supports a template function object (which supports operator ()).
When the receiver function is an object method, the signal will automatically be disconnected when the object is deleted, as long as the object inherits from WObject (or Wt::Signals::trackable).
Connects a slot that is specified as JavaScript only.
This will provide a client-side connection between the event and some JavaScript code as implemented by the slot. Unlike other connects, this does not cause the event to propagated to the application, and thus the state changes caused by the JavaScript slot are not tracked client-side.
The connection is tracked, taking into account the life-time of the JSlot object, and can be updated by modifying the slot
. If you do not need connection management (e.g. because the slot has the same life-time as the signal), then you can use connect(const
std::string&) instead.
Wt::Signals::connection Wt::EventSignal< E >::connect | ( | T * | target, |
void(V::*)() | method | ||
) |
Connects a slot that takes no arguments.
If a stateless implementation is specified for the slot, then the visual behaviour will be learned in terms of JavaScript, and will be cached on the client side for instant feed-back, in addition running the slot on the server.
The slot is as a method
of an object target
of class T
, which equals class V
, or is a base class of class V
. In addition, to check for stateless implementations, class T
must be also be a descendant of WObject. Thus, the following statement must return a non-null pointer:
Connects a slot that takes a 'const argument&'.
This is only possible for signals that take at least one argument.
Wt::Signals::connection Wt::EventSignal< E >::connect | ( | T * | target, |
void(V::*)(E) | method | ||
) |
Connects a slot that takes one argument.
This is only possible for signals that take at least one argument.
|
overridevirtual |
Connects to a slot.
Every signal can be connected to a slot which does not take any arguments (and may thus ignore signal arguments).
Implements Wt::SignalBase.
Emits the signal.
This will cause all connected slots to be triggered, with the given argument.