#include <WJavaScript>
Inherited by Wt::JSignal< void >.
Public Member Functions | |
| JSignal (WObject *object, const std::string name) | |
| Construct a signal for the given object, and name. | |
| std::string | name () const |
| Get the name of this signal. | |
| virtual bool | isConnected () const |
| Is this signal connected to at least one slot ? | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)()) |
| Connect a slot that takes no arguments. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1)) |
| Connect a slot that takes one argument. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1, A2)) |
| Connect a slot that takes two arguments. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1, A2, A3)) |
| Connect a slot that takes three arguments. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4)) |
| Connect a slot that takes four arguments. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4, A5)) |
| Connect a slot that takes five arguments. | |
| template<class T, class V> | |
| boost::signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4, A5, A6)) |
| Connect a slot that takes six arguments. | |
| void | emit (A1 a1=None::none, A2 a2=None::none, A3 a3=None::none, A4 a4=None::none, A5 a5=None::none, A6 a6=None::none) |
| Emit the signal. | |
| void | operator() (A1 a1=None::none, A2 a2=None::none, A3 a3=None::none, A4 a4=None::none, A5 a5=None::none, A6 a6=None::none) |
| Emit the signal. | |
A JSignal, like an EventSignal, provides communicates events from JavaScript to C++ code. However, it not tied to a built-in event. Instead, it can be emitted from within custom JavaScript code using the JavaScript WtEmitSignal() function.
The signal is identified by a unique name, within the scope of a WObject, which are specified in its constructor.
The signal supports up to 6 arguments. Values for these arguments may be specified in the JavaScript WtEmitSignal().
For example, consider the following signal, and constructor:
class MyWidget : public WCompositeWidget
{
public:
// ...
JSignal<std::string, int> doSome;
// ...
};
MyWidget::MyWidget()
: doSome(this, "dosome")
{
//...
}
The following JavaScript code will then emit the signal for a DOM element, which corresponds to a MyWidget widget:
WtSignalEmit(element, 'dosome', 'foo', 42);
The conversion between the JavaScript argument (ax) and the C++ type Ax uses boost::lexical_cast<Ax>(ax).
| Wt::JSignal< A1, A2, A3, A4, A5, A6 >::JSignal | ( | WObject * | object, | |
| const std::string | name | |||
| ) |
Construct a signal for the given object, and name.
The name must be unique for all user signals specified for a single class.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1, A2, A3, A4, A5, A6) | method | |||
| ) |
Connect a slot that takes six arguments.
This is only possible for signals that take at least six arguments.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1, A2, A3, A4, A5) | method | |||
| ) |
Connect a slot that takes five arguments.
This is only possible for signals that take at least five arguments.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1, A2, A3, A4) | method | |||
| ) |
Connect a slot that takes four arguments.
This is only possible for signals that take at least four arguments.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1, A2, A3) | method | |||
| ) |
Connect a slot that takes three arguments.
This is only possible for signals that take at least three arguments.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1, A2) | method | |||
| ) |
Connect a slot that takes two arguments.
This is only possible for signals that take at least two arguments.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)(A1) | method | |||
| ) |
Connect a slot that takes one argument.
This is only possible for signals that take at least one argument.
| boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, | |
| void(V::*)() | method | |||
| ) |
Connect a slot that takes no arguments.
This is always possible (even when the signal specifies a number of arguments).
The slot is specified as a method of class V, which is equal to class V, or a base class of class V. Thus, the following statement must return a non-null pointer:
V *v = dynamic_cast<V *>(target);
In practice, to facilitate automatic disconnects on deletion of the target, class T must be also be a descendant of WObject, but this is not enforced by the interface.
| void Wt::JSignal< A1, A2, A3, A4, A5, A6 >::emit | ( | A1 | a1 = None::none, |
|
| A2 | a2 = None::none, |
|||
| A3 | a3 = None::none, |
|||
| A4 | a4 = None::none, |
|||
| A5 | a5 = None::none, |
|||
| A6 | a6 = None::none | |||
| ) |
Emit the signal.
The arguments must exactly match the arguments of the target function.
This will cause all connected slots to be triggered, with the given arguments.
| void Wt::JSignal< A1, A2, A3, A4, A5, A6 >::operator() | ( | A1 | a1 = None::none, |
|
| A2 | a2 = None::none, |
|||
| A3 | a3 = None::none, |
|||
| A4 | a4 = None::none, |
|||
| A5 | a5 = None::none, |
|||
| A6 | a6 = None::none | |||
| ) |
1.4.7