Wt  3.7.1
Namespaces | Classes | Enumerations
Signal/slot system

Support for event handling using signals and slots. More...

Namespaces

 Wt::Signals
 Namespace for signal/slot implementation.
 

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< A1, A2, A3, A4, A5, A6 >
 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< A1, A2, A3, A4, A5, A6 >
 A signal that propagates events to listeners. More...
 
class  Wt::EventSignal< E >
 A signal that conveys user-interface events. More...
 
class  Wt::WSignalMapper< T, A1 >
 A utility class to connect multiple senders to a single slot. More...
 

Enumerations

enum  Wt::KeyboardModifier {
  Wt::NoModifier = 0x0, Wt::ShiftModifier = 0x1, Wt::ControlModifier = 0x2, Wt::AltModifier = 0x4,
  Wt::MetaModifier = 0x8
}
 Enumeration for keyboard modifiers. More...
 
enum  Wt::Key {
  Wt::Key_unknown = 0, Wt::Key_Enter = 13, Wt::Key_Tab = 9, Wt::Key_Backspace = 8,
  Wt::Key_Shift = 16, Wt::Key_Control = 17, Wt::Key_Alt = 18, Wt::Key_PageUp = 33,
  Wt::Key_PageDown = 34, Wt::Key_End = 35, Wt::Key_Home = 36, Wt::Key_Left = 37,
  Wt::Key_Up = 38, Wt::Key_Right = 39, Wt::Key_Down = 40, Wt::Key_Insert = 45,
  Wt::Key_Delete = 46, Wt::Key_Escape = 27, Wt::Key_F1 = 112, Wt::Key_F2 = 113,
  Wt::Key_F3 = 114, Wt::Key_F4 = 115, Wt::Key_F5 = 116, Wt::Key_F6 = 117,
  Wt::Key_F7 = 118, Wt::Key_F8 = 119, Wt::Key_F9 = 120, Wt::Key_F10 = 121,
  Wt::Key_F11 = 122, Wt::Key_F12 = 123, Wt::Key_Space = ' ', Wt::Key_A = 'A',
  Wt::Key_B = 'B', Wt::Key_C = 'C', Wt::Key_D = 'D', Wt::Key_E = 'E',
  Wt::Key_F = 'F', Wt::Key_G = 'G', Wt::Key_H = 'H', Wt::Key_I = 'I',
  Wt::Key_J = 'J', Wt::Key_K = 'K', Wt::Key_L = 'L', Wt::Key_M = 'M',
  Wt::Key_N = 'N', Wt::Key_O = 'O', Wt::Key_P = 'P', Wt::Key_Q = 'Q',
  Wt::Key_R = 'R', Wt::Key_S = 'S', Wt::Key_T = 'T', Wt::Key_U = 'U',
  Wt::Key_V = 'V', Wt::Key_W = 'W', Wt::Key_X = 'X', Wt::Key_Y = 'Y',
  Wt::Key_Z = 'Z', Wt::Key_1 = '1', Wt::Key_2 = '2', Wt::Key_3 = '3',
  Wt::Key_4 = '4', Wt::Key_5 = '5', Wt::Key_6 = '6', Wt::Key_7 = '7',
  Wt::Key_8 = '8', Wt::Key_9 = '9', Wt::Key_0 = '0'
}
 Enumeration for key codes. More...
 

Detailed Description

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 boost::bind() to identify the sender (or otherwise the intention) of the signal. The use of class WSignalMapper<T> is discouraged.

Usage example:

std::vector<Wt::WPushButton*> buttons = ...;
for(unsigned i = 0; i < buttons.size(); ++i) {
buttons[i]->clicked().connect(boost::bind(&Keyboard::handleClick, i));
}
void Keyboard::handleClick(int i) {
t->setText(WString("You pressed button {1}").args(i));
}

Enumeration Type Documentation

◆ Key

enum Wt::Key

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.

See also
WInteractWidget::keyWentDown, WInteractWidget::keyWentUp
Enumerator
Key_unknown 

Unknown key.

Key_Enter 

Enter key.

Key_Tab 

Tab key.

Key_Backspace 

Backspace key.

Key_Shift 

Shift key.

Key_Control 

Control key.

Key_Alt 

Alt key.

Key_PageUp 

Page up key.

Key_PageDown 

Page down key.

Key_End 

End key.

Key_Home 

Home key.

Key_Left 

Left arrow key.

Key_Up 

Up arrow key.

Key_Right 

Right arrow key.

Key_Down 

Down arrow key.

Key_Insert 

Insert key.

Key_Delete 

Delete key.

Key_Escape 

Escape key.

Key_F1 

F1 function key.

Key_F2 

F2 function key.

Key_F3 

F3 function key.

Key_F4 

F4 function key.

Key_F5 

F5 function key.

Key_F6 

F6 function key.

Key_F7 

F7 function key.

Key_F8 

F8 function key.

Key_F9 

F9 function key.

Key_F10 

F10 function key.

Key_F11 

F11 function key.

Key_F12 

F12 function key.

Key_Space 

Space.

Key_A 

'A' key

Key_B 

'B' key

Key_C 

'C' key

Key_D 

'D' key

Key_E 

'E' key

Key_F 

'F' key

Key_G 

'G' key

Key_H 

'H' key

Key_I 

'I' key

Key_J 

'J' key

Key_K 

'K' key

Key_L 

'L' key

Key_M 

'M' key

Key_N 

'N' key

Key_O 

'O' key

Key_P 

'P' key

Key_Q 

'Q' key

Key_R 

'R' key

Key_S 

'S' key

Key_T 

'T' key

Key_U 

'U' key

Key_V 

'V' key

Key_W 

'W' key

Key_X 

'X' key

Key_Y 

'Y' key

Key_Z 

'Z' key

Key_1 

'1' key

Key_2 

'2' key

Key_3 

'3' key

Key_4 

'4' key

Key_5 

'5' key

Key_6 

'6' key

Key_7 

'7' key

Key_8 

'8' key

Key_9 

'9' key

Key_0 

'0' key

◆ KeyboardModifier

Enumeration for keyboard modifiers.

See also
WMouseEvent::modifiers(), WKeyEvent::modifiers()
Enumerator
NoModifier 

No modifiers.

ShiftModifier 

Shift key pressed.

ControlModifier 

Control key pressed.

AltModifier 

Alt key pressed.

MetaModifier 

Meta key pressed ("Windows" or "Command" (Mac) key)


Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13