beeware / beeware/toga

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

Open
#2,805 7 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
9h 45m
Merged PRs (30d)
58

Description

### 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 and other automatic content modification behaviors.

We should add the following boolean flags to both widgets:
* `spell_checking` (to disable spell checkers)
* `smart_quotes` (to disable smart quote and em-dash expansions)

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

### Describe alternatives you've considered

In the process of implementing this, we should keep an eye out for other "text modification" features that might be worth exposing as similar boolean flags. However, a fix incorporating only these two flags is sufficient.

### Additional context

Originally reported as #2801.

#3546 reported the issue with smart quote handling.

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](https://developer.android.com/reference/android/text/InputType) seems to have a number of other options that can be disabled.

iOS provides [`spellCheckingType`](https://developer.apple.com/documentation/uikit/uitextinputtraits/1624461-spellcheckingtype?language=objc), [`autocorrectionType`](https://developer.apple.com/documentation/uikit/uitextinputtraits/1624453-autocorrectiontype?language=objc) and a number of other properties for configuration automated tools.

Contributor guide

Open the contributing guide

Research direction

Start at the TextInput and MultilineTextInput entry points and trace their platform implementations. Compare Android's InputType flags with iOS's spellCheckingType and autocorrectionType; done means both widgets expose spell_checking and smart_quotes, supported platforms honor them, and unsupported platforms are documented as quirks.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, ios, python
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.