beeware/toga

Add API to control spell checkers and other platform-provided text input assistants

Open

#2,805 创建于 2024年9月1日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Python (3,615 star) (624 fork)batch import
enhancementgood first issue

描述

What is the problem or limitation you are having?

It is common for test input fields to have spellcheck helpers, especially on mobile platforms. This is extremely useful when the input is human-readable text, but if an input is something like an input of a family name, or ID number, or anything else that is decidedly not a natural language word, red underlined words and spell check corrections can be something between an annoyance and an active hindrance.

Describe the solution you'd like

TextInput and MultilineTextInput should have a mechanism to disable auto spell check.

A boolean flag to the TextInput constructor (spell_checking=False) would be sufficient to control spelling specifically.

Describe alternatives you've considered

It may be worth investigating if there are other input features that we might want to turn off (e.g., autocorrect, autocomplete, autocapitalisation, predictive text). Depending on how many of these features exist, and how common they are across platforms, it might be worthwhile considering adding support for those features as well.

If a platform doesn't provide the feature at all, the feature should be ignored (and documented as such as a platform quirk).

Additional context

Originally reported as #2801.

In that ticket, @rmartin16 provided the functional implementation for Android:

text_input = toga.TextInput()

if toga.platform.current_platform == "android":
    from android.text import InputType
    text_input._impl.native.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)

The InputType enum seems to have a number of other options that can be disabled.

iOS provides spellCheckingType, autocorrectionType and a number of other properties for configuration automated tools.

贡献者指南

Add API to control spell checkers and other platform-provided text input assistants · beeware/toga#2805 | Good First Issue