Skip to content

Upstreaming text input #19752

Open
Open
@viridia

Description

@viridia

What problem does this solve or what need does it fill?

This is a follow-on to #6213 - that issue is about the need for a text input field in general, this issue focuses on the specific proposal of upstreaming @ickshonpe 's text input widget: https://github.com/ickshonpe/bevy_ui_text_input

Part of the goal in this release cycle is to make progress on the "editor-ready" widgets (See #254) and text input is a critical component of this. Moreover, while it's relatively easy to code up a half-baked text input, doing one that has all of the quality and features that users would expect requires subtlety and skill. Fortunately, the implementation linked above leverages all of the work from cosmic-text and so should be a sound basis to build on.

What solution would you like?

What I'd like is for the text edit widget to follow the same general structure as the other "core widgets": a headless version in bevy_core_widgets, and then an opinionated version in bevy_feathers.

Note that in order to be useful, a text editor can't be entirely headless: it has to do some rendering and styling. That's OK: the definition of "headless" doesn't mean "no styling at all" but rather something more like "give the developer as much styling flexibility as is feasible". Styles which are fundamental to the operation of the widget should be part of the headless code.

Certain style properties might need to be passed in as parameters. I've had good success with using marker components in the headless widget, and then having the opinionated widget look for those markers and add styles afterwards.

Scope: I don't think that the core input widget should support rich text. In the web world, there are many text input widget libraries, some of which are rich and others not. In general, the rich input widgets have a very different API and developer experience. They tend to be much more complex and have a steep learning curve. For games and editors, 99% of the use cases are for entering a character name, saved game name, or asset name, which don't require much more than a single line of unstyled text.

Similarly, I don't care about syntax highlighting. On the plus side, syntax highlighting doesn't change the API nearly as much as rich text. But I'm not willing to wait an extra six months to get it. Also, other than (maybe) the Bevy editor, there are virtually no use cases for it in games.

Instead, the more advanced use case we should be thinking about is in-game chat. This means:

  • support for multi-line text (which we have)
  • support for bidirectional input (not sure if we have this now). Mainly this affects picking and can cause selection rectangles to be visually discontiguous.
  • support for IMEs (not there yet, but on the TODO list)

What alternative(s) have you considered?

The alternatives I have considered are:

  • Write my own widget based on cosmic text or parley (which I really don't want to do)
  • Choose one of the other Bevy text input widgets that have been built (which frankly I don't have as much confidence in).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions