Support for event handling using signals and slots.
More...
|
| enum class | Wt::KeyboardModifier {
Wt::KeyboardModifier::None = 0x0
, Wt::KeyboardModifier::Shift = 0x1
, Wt::KeyboardModifier::Control = 0x2
, Wt::KeyboardModifier::Alt = 0x4
,
Wt::KeyboardModifier::Meta = 0x8
} |
| | Enumeration for keyboard modifiers. More...
|
| |
| enum class | Wt::Key {
Wt::Key::Unknown = 0
, Wt::Key::Enter = 13
, Wt::Key::Tab = 9
, Wt::Key::Backspace = 8
,
Wt::Key::Clear = 12
, Wt::Key::Shift = 16
, Wt::Key::Control = 17
, Wt::Key::Alt = 18
,
Wt::Key::Pause = 19
, Wt::Key::Escape = 27
, 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::Meta = 91
, Wt::Key::ContextMenu = 93
, Wt::Key::Numpad0 = 96
, Wt::Key::Numpad1 = 97
,
Wt::Key::Numpad2 = 98
, Wt::Key::Numpad3 = 99
, Wt::Key::Numpad4 = 100
, Wt::Key::Numpad5 = 101
,
Wt::Key::Numpad6 = 102
, Wt::Key::Numpad7 = 103
, Wt::Key::Numpad8 = 104
, Wt::Key::Numpad9 = 105
,
Wt::Key::NumMultiply = 106
, Wt::Key::NumAdd = 107
, Wt::Key::NumSeparator = 108
, Wt::Key::NumSubtract = 109
,
Wt::Key::NumDecimal = 110
, Wt::Key::NumDivide = 111
, 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::OemSemicolon = 186
, Wt::Key::OemPlus = 187
,
Wt::Key::OemComma = 188
, Wt::Key::OemMinus = 189
, Wt::Key::OemPeriod = 190
, Wt::Key::OemQuestion = 191
,
Wt::Key::OemTilde = 192
, Wt::Key::OemOpenBrackets = 219
, Wt::Key::OemPipe = 220
, Wt::Key::OemCloseBrackets = 221
,
Wt::Key::OemQuotes = 222
, Wt::Key::OemBackslash = 226
, 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::Key_1 = '1'
, Wt::Key::Key_2 = '2'
, Wt::Key::Key_3 = '3'
,
Wt::Key::Key_4 = '4'
, Wt::Key::Key_5 = '5'
, Wt::Key::Key_6 = '6'
, Wt::Key::Key_7 = '7'
,
Wt::Key::Key_8 = '8'
, Wt::Key::Key_9 = '9'
, Wt::Key::Key_0 = '0'
} |
| | Enumeration for key codes. 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:
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));
}
◆ 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 |
|---|
| Unknown | Unknown key.
|
| Enter | Enter key.
|
| Tab | Tab key.
|
| Backspace | Backspace key.
|
| Clear | Clear key.
|
| Shift | Shift key.
|
| Control | Control key.
|
| Alt | Alt key.
|
| Pause | Pause key.
|
| Escape | Escape 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.
|
| Meta | Meta / Windows key.
|
| ContextMenu | Context menu / Apps key.
|
| Numpad0 | '0' num pad key.
|
| Numpad1 | '1' num pad key.
|
| Numpad2 | '2' num pad key.
|
| Numpad3 | '3' num pad key.
|
| Numpad4 | '4' num pad key.
|
| Numpad5 | '5' num pad key.
|
| Numpad6 | '6' num pad key.
|
| Numpad7 | '7' num pad key.
|
| Numpad8 | '8' num pad key.
|
| Numpad9 | '9' num pad key.
|
| NumMultiply | '*' num pad key.
|
| NumAdd | '+' num pad key.
|
| NumSeparator | ',' num pad key.
|
| NumSubtract | '-' num pad key.
|
| NumDecimal | '.' num pad key.
|
| NumDivide | '/' num pad 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.
|
| OemSemicolon | Configuration-dependent key.
|
| OemPlus | Configuration-dependent key.
|
| OemComma | Configuration-dependent key.
|
| OemMinus | Configuration-dependent key.
|
| OemPeriod | Configuration-dependent key.
|
| OemQuestion | Configuration-dependent key.
|
| OemTilde | Configuration-dependent key.
- Note
- Cannot be distinguished from OemCloseBrackets in Firefox!
|
| OemOpenBrackets | Configuration-dependent key.
|
| OemPipe | Configuration-dependent key.
|
| OemCloseBrackets | Configuration-dependent key.
- Note
- Cannot be distinguished from OemTilde in Firefox!
|
| OemQuotes | Configuration-dependent key.
|
| OemBackslash | Configuration-dependent key.
|
| Space | Space.
|
| A | 'A' key
|
| B | 'B' key
|
| C | 'C' key
|
| D | 'D' key
|
| E | 'E' key
|
| F | 'F' key
|
| G | 'G' key
|
| H | 'H' key
|
| I | 'I' key
|
| J | 'J' key
|
| K | 'K' key
|
| L | 'L' key
|
| M | 'M' key
|
| N | 'N' key
|
| O | 'O' key
|
| P | 'P' key
|
| Q | 'Q' key
|
| R | 'R' key
|
| S | 'S' key
|
| T | 'T' key
|
| U | 'U' key
|
| V | 'V' key
|
| W | 'W' key
|
| X | 'X' key
|
| Y | 'Y' 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 |
|---|
| None | No modifiers.
|
| Shift | Shift key pressed.
|
| Control | Control key pressed.
|
| Alt | Alt key pressed.
|
| Meta | Meta key pressed ("Windows" or "Command" (Mac) key)
|