Skip to content
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

Parley cannot compute caret geometry if layout text is empty #135

Open
nicoburns opened this issue Oct 10, 2024 · 3 comments
Open

Parley cannot compute caret geometry if layout text is empty #135

nicoburns opened this issue Oct 10, 2024 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@nicoburns
Copy link
Contributor

The following screen capture shows the issue. This is using a PlainEditor and drawing the selection/caret as in the vello_editor example. Note that there is initially no caret even though the input is focssed. The caret shows once some text has been typed in the field and disappears again when the text is deleted.

Screen.Recording.2024-10-10.at.22.32.02.mov
@nicoburns nicoburns added the bug Something isn't working label Oct 10, 2024
@nicoburns nicoburns added this to the 0.3 Release milestone Oct 10, 2024
@xorgy
Copy link
Member

xorgy commented Oct 11, 2024

Yeah, this is similar I think to the issue of caret position downstream of a hard line break.

@dfrg
Copy link
Collaborator

dfrg commented Oct 12, 2024

This is actually because the layout is empty therefore we don’t do any font selection and have no metrics from which to generate cursor geometry. My upcoming code has a hack to address this by forcing layout of a single space (which used to be there but was removed at some point). There’s definitely a better way to do this but I plan to defer that to the larger refactor.

@nicoburns
Copy link
Contributor Author

Ah yes, I removed that in #67 because, well, it seemed like a hack (and improvements in #67 meant that it would no longer panic when the string was empty). I guess the space hack will work but we'll need to keep track that we're in that "mode" so that we don't allow the space to be selected, etc.

There is actually another "mode" that I want which could probably work similarly: placeholder text. Which I am imagining working by having a second text string and set of styles that would be used as a fallback when the main string is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants