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

Text can't be selected #7

Closed
zikajk opened this issue Sep 17, 2023 · 11 comments
Closed

Text can't be selected #7

zikajk opened this issue Sep 17, 2023 · 11 comments

Comments

@zikajk
Copy link

zikajk commented Sep 17, 2023

Hi! Is there any reason why the text can not be selected (SelectableText class)?

@amake
Copy link
Owner

amake commented Sep 17, 2023

In general you can select the text. Can you be more specific about what or where you're having trouble?

image

@zikajk
Copy link
Author

zikajk commented Sep 17, 2023

That is interesting!
I am testing the app in browser and simulator and I am not able to select anything.
image

@kresimir71
Copy link

I have the same experience with web pages created by Flutter. I've always assumed this is normal behavior because it's not HTML, it's a graphical output that doesn't use HTML.

@zikajk
Copy link
Author

zikajk commented Sep 17, 2023

I have the same experience with web pages created by Flutter. I've always assumed this is normal behavior because it's not HTML, it's a graphical output that doesn't use HTML.

Once I use SelectableText class, then I can select the text (tested in one of buttons on the left side).

@amake
Copy link
Owner

amake commented Sep 17, 2023

Oops.

The screenshot I showed above was from Orgro, and while I remembered correctly that Flutter had changed something about how selection works such that SelectableText is not needed, I forgot the details of it.

In Orgro I wrap the relevant widget in SelectionArea. That seems to be sufficient to allow selection inside the Org document.

I did experiment with using SelectableText in org_flutter in the past, but

  1. I found there were differences in rendering, and I didn't want to try to figure out why
  2. Sometimes you don't want things to be selectable. For instance with the introduction of the OrgText widget, you can use Org markup to easily create a rich Text equivalent, which in the general case should not be selectable by default.

@zikajk
Copy link
Author

zikajk commented Sep 17, 2023

Great, I didn't know about SelectionArea. It fullfills all my needs. Thank you for the info 🙏

@amake
Copy link
Owner

amake commented Sep 17, 2023

I've updated the readme to mention SelectionArea. I don't want to make any of org_flutter's widgets selectable by default per above, so I'll close this.

@amake amake closed this as completed Sep 17, 2023
@zikajk
Copy link
Author

zikajk commented Sep 18, 2023

@amake Can you select source-blocks in Orgro?
SelectionArea seems to have no effect.

And to add, really nice work, thank you for this!

@amake
Copy link
Owner

amake commented Sep 18, 2023

You can select source blocks but only if they don't have syntax highlighting applied (no language specified, or the language is not supported by flutter_highlight).

I haven't looked into why selection doesn't work with that package, but I do note that it seems abandoned and other, newer packages are available, so I am looking at moving to one of them.

@amake
Copy link
Owner

amake commented Sep 18, 2023

It looks like the reason is because flutter_highlight uses a new RichText widget:
https://github.com/git-touch/highlight.dart/blob/8c08291d18d1e3fdab8564cc3f09726e262e555d/flutter_highlight/lib/flutter_highlight.dart#L93

Apparently you can make a RichText participate in the surrounding selection context relatively easily, but it requires a change to their library:
https://api.flutter.dev/flutter/widgets/RichText-class.html#selections

@amake
Copy link
Owner

amake commented Sep 19, 2023

I have opened a fix for the issue with flutter_highlighting:
akvelon/dart-highlighting#71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants