Skip to content

ui::ModifierKeys

Header: winui/core/Input.hpp.

The modifier keys held with a key or a pointer event, and the ones a KeyCombo asks for.

Example:

class ListControl : public ui::Element
{
protected:
    bool pointer_override(const ui::PointerEvent& e) override
    {
        if (e.action == ui::PointerAction::Down && e.modifiers.shift)
        {
            extend_selection_to(e.position);
            return true;
        }
        return false;
    }

    bool key_override(const ui::KeyEvent& e) override
    {
        // Exactly Ctrl+Shift, nothing else held.
        return e.modifiers == ui::ModifierKeys{.ctrl = true, .shift = true};
    }

private:
    void extend_selection_to(ui::Point position);
};

ctrl

bool ctrl = false

Ctrl.

shift

bool shift = false

Shift.

alt

bool alt = false

Alt.

win

bool win = false

The Windows logo key.

none

bool none() const

True when no modifier is held.