Wt  4.11.1
Classes | Enumerations
Signal/slot system

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...
 

Enumerations

enum class  Wt::KeyboardModifier {
  Wt::None = 0x0 , Wt::Shift = 0x1 , Wt::Control = 0x2 , Wt::Alt = 0x4 ,
  Wt::Meta = 0x8
}
 Enumeration for keyboard modifiers. More...
 
enum class  Wt::Key {
  Wt::Unknown = 0 , Wt::Enter = 13 , Wt::Tab = 9 , Wt::Backspace = 8 ,
  Wt::Shift = 16 , Wt::Control = 17 , Wt::Alt = 18 , Wt::PageUp = 33 ,
  Wt::PageDown = 34 , Wt::End = 35 , Wt::Home = 36 , Wt::Left = 37 ,
  Wt::Up = 38 , Wt::Right = 39 , Wt::Down = 40 , Wt::Insert = 45 ,
  Wt::Delete = 46 , Wt::Escape = 27 , Wt::F1 = 112 , Wt::F2 = 113 ,
  Wt::F3 = 114 , Wt::F4 = 115 , Wt::F5 = 116 , Wt::F6 = 117 ,
  Wt::F7 = 118 , Wt::F8 = 119 , Wt::F9 = 120 , Wt::F10 = 121 ,
  Wt::F11 = 122 , Wt::F12 = 123 , Wt::Space = ' ' , Wt::A = 'A' ,
  Wt::B = 'B' , Wt::C = 'C' , Wt::D = 'D' , Wt::E = 'E' ,
  Wt::F = 'F' , Wt::G = 'G' , Wt::H = 'H' , Wt::I = 'I' ,
  Wt::J = 'J' , Wt::K = 'K' , Wt::L = 'L' , Wt::M = 'M' ,
  Wt::N = 'N' , Wt::O = 'O' , Wt::P = 'P' , Wt::Q = 'Q' ,
  Wt::R = 'R' , Wt::S = 'S' , Wt::T = 'T' , Wt::U = 'U' ,
  Wt::V = 'V' , Wt::W = 'W' , Wt::X = 'X' , Wt::Y = 'Y' ,
  Wt::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 std::bind() to identify the sender (or otherwise the intention) of the signal.

Usage example:

std::vector<Wt::WPushButton*> buttons = ...;
for(unsigned i = 0; i < buttons.size(); ++i) {
buttons[i]->clicked().connect(std::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
strong

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
Unknown 

Unknown key.

Enter 

Enter key.

Tab 

Tab key.

Backspace 

Backspace key.

Shift 

Shift key.

Control 

Control key.

Alt 

Alt key.

PageUp 

Page up key.

PageDown 

Page down key.

End 

End key.

Home 

Home key.

Left 

Left arrow key.

Up 

Up arrow key.

Right 

Right arrow key.

Down 

Down arrow key.

Insert 

Insert key.

Delete 

Delete key.

Escape 

Escape key.

F1 

F1 function key.

F2 

F2 function key.

F3 

F3 function key.

F4 

F4 function key.

F5 

F5 function key.

F6 

F6 function key.

F7 

F7 function key.

F8 

F8 function key.

F9 

F9 function key.

F10 

F10 function key.

F11 

F11 function key.

F12 

F12 function key.

Space 

Space.

'A' key

'B' key

'C' key

'D' key

'E' key

'F' key

'G' key

'H' key

'I' key

'J' key

'K' key

'L' key

'M' key

'N' key

'O' key

'P' key

'Q' key

'R' key

'S' key

'T' key

'U' key

'V' key

'W' key

'X' key

'Y' key

'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

enum Wt::KeyboardModifier
strong

Enumeration for keyboard modifiers.

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

No modifiers.

Shift 

Shift key pressed.

Control 

Control key pressed.

Alt 

Alt key pressed.

Meta 

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