Skip to content

Implement TextEditor #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 23, 2025
Merged

Implement TextEditor #187

merged 5 commits into from
Jun 23, 2025

Conversation

stackotter
Copy link
Owner

This PR introduces a TextEditor control for editing multi-line text. For now it's borderless (i.e. has all platform-specific 'text field' looking styles disabled) to allow for it to be used in the widest variety of use cases.

The text editor background in the NotesExample app (see screenshots below) was added using the background modifier and doesn't come with the text editor (unstyled by default).

Other changes

  • Added default Edit menu items to AppKitBackend's default menu to enable keyboard shortcuts such as cmd+a, cmd+c, cmd+v etc to be used in text inputs.
  • Fixed background modifier's propagation of idealHeightForWidth and idealWidthForHeight (previously just set to the child view's idealSize.x and idealSize.y)
  • Fixed ScrollView's sizing behaviour (to a certain extent; just enough to fix NotesExample)

Known issues

  • GtkBackend and Gtk3Backend overestimate the required height of text editors by about half a pixel per line of text (or less) on macOS (but work fine on Linux).

Future directions

  • A textEditorStyle modifier to allow platform-specific decorations to be enabled (so that text editors can fit in with text fields for form-like use cases)

Screenshots

AppKit

Screenshot 2025-06-22 at 1 15 27 pm

WinUI

Gtk 4

Gtk 3

The missing border radius is a known issue for Gtk3Backend.

UIKit

@stackotter stackotter added the feature A feature request label Jun 22, 2025
Copy link
Owner Author

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix these when I'm back at my laptop, then I'll merge.

@stackotter stackotter merged commit 7582a12 into main Jun 23, 2025
20 checks passed
@stackotter stackotter deleted the text_editor branch June 23, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant