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

Allow disabled TextInput to still be interacted with #2262

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

Koranir
Copy link
Contributor

@Koranir Koranir commented Feb 18, 2024

Resolves #1880

Follows Firefox's text selection usage (i.e. no blinking cursor, arrow keys don't do anything unless shift is pressed, cursor click position is remembered).

Draft for the following reasons:

  • Should the placeholder text be selectable?
  • Should this apply to TextEditors as well?
  • Currently, the allowed operations when disabled are copy and select all in addition to the selection primitives. Should there be more?

@habics
Copy link

habics commented Feb 27, 2024

  • Should this apply to TextEditors as well?

Yes please, imo TextEditor is a TextInput on steroids, it should have all the behavior of TextInput plus more features.
There are many befits to have this behavior for TextEditor as well, for example using it to display long informational text that can be copied without editing it.

@Koranir
Copy link
Contributor Author

Koranir commented Feb 29, 2024

  • Should this apply to TextEditors as well?

Yes please, imo TextEditor is a TextInput on steroids, it should have all the behavior of TextInput plus more features. There are many befits to have this behavior for TextEditor as well, for example using it to display long informational text that can be copied without editing it.

Now that I've taken a closer look at the TextEditor architecture, it seems impossible to add this, as the TextEditor's state is held by the user. This means that the user has to provide a way to manipulate the state via the set_action method, but that would enable the text input instead.

(Actually, it seems like the end user can just discard actions by the TextEditor that would modify the file contents, so it would pretty much be the same as a normal display.)

What would be more appropriate would be to have a separate TextDisplay or similar widget that provides copy/paste capabilities and maybe some additional customisation options.

@Koranir Koranir marked this pull request as ready for review February 29, 2024 00:46
@habics
Copy link

habics commented Feb 29, 2024

@Koranir
I understand, thank you for taking a closer look.

Co-authored-by: Daniel Yoon <101683475+Koranir@users.noreply.github.com>
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Thanks!

Made some changes here and there. Hopefully I didn't break anything.

@hecrj hecrj enabled auto-merge September 4, 2024 18:29
@hecrj hecrj merged commit 8d826cc into iced-rs:master Sep 4, 2024
12 checks passed
@hecrj hecrj added this to the 0.13 milestone Sep 5, 2024
@hecrj hecrj added feature New feature or request text widget addition labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabled TextInput should still allow mouse interaction, selection and copying
3 participants