Skip to content

ui::SpellingError

Header: winui/render/SpellChecker.hpp.

One finding of SpellChecker::check(): a range of the checked text and what to do about it.

Example:

void autocorrect(ui::SpellChecker& checker, std::string& text)
{
    for (const ui::SpellingError& e : checker.check(text))
    {
        if (e.action == ui::SpellingAction::Replace && checker.autocorrect_enabled())
        {
            text.replace(e.start, e.length, e.replacement);
            break; // offsets after this one are stale now
        }
    }
}

Field Type Default
start std::size_t 0 Offset of the range in the checked text.
length std::size_t 0 Length of the range.
action SpellingAction SpellingAction::Suggest What the checker suggests doing.
replacement std::string The correction; valid only for SpellingAction::Replace.