ui::KeyCombo¶
Header: winui/core/Input.hpp.
A key and its modifiers, without the action it runs. Menu items, app-bar buttons and commands carry their shortcut in it. The key combination fires app-wide (Element::handle_global_shortcut()) and its text() is shown beside the item. Key::Unknown is no shortcut. Written the way the menu shows it, ui::Ctrl + ui::Shift + ui::Key::N, or as a bare key, ui::Key::F4. Alt key combinations work, except the ones the system owns (Alt+F4, Alt+Space, Alt+Tab, Alt+Esc), which never reach the window.
Example:
const ui::KeyCombo save = ui::Ctrl + ui::Key::S;
const std::string hint = save.text(); // "Ctrl+S", what a menu shows beside the label
// In a key handler: is this the key combination?
window.on_key_preview([save](const ui::KeyEvent& event)
{
if (save.matches(event))
{
save_document();
return ui::Handled;
}
return ui::NotHandled;
});
key¶
The key; Unknown means "no shortcut".
modifiers¶
Exactly the modifiers that must be held.
KeyCombo¶
No shortcut.
KeyCombo¶
The key alone, so a field takes ui::Key::F4.
KeyCombo¶
The key with mods held: ui::KeyCombo{ui::Key::S, {.ctrl = true}}.
empty¶
True for Key::Unknown, i.e. no shortcut assigned.
matches¶
True if e is a key-down of exactly this key combination: the same key and exactly the same modifiers. Always false for an empty() combination and for key-up events.
text¶
"Ctrl+S" (shortcut_text()); empty for an empty() combination.