It seems that since 1.0.0-alpha05, `Text` is no lo...
# compose
l
It seems that since 1.0.0-alpha05,
Text
is no longer selectable by default. How can we make it selectable again?
s
Add a SelectionContainer around the tree that you want to be selectable
l
I wrapped with
SelectionContainer(selection = null, onSelectionChange = {}) { … }
but while I can select the text, I can't do anything with it, there's no popup/toolbar appearing above… why is it not there by default and is there a way to get that popup/toolbar?
s
The answer to why it is not enabled by default would be complicated for me. I am on the same school of thought that it should be enabled by default.
I will add a simpler api but for now you should not set selection to null
It should be like TextField etc where you get rhe selection on the callback and set the value that was passed
As long as you can add SelectionContainer to any component tree that has text, they will be selectable. (If there is not a specific bug)
l
It's unclear which value I should pass to
selection
though since I just want text from the composition to be selectable, regardless of what it is.
s
The value you get from onSelectionChange goes into selection attribute?
z
Copy code
var selection: Selection? by remember { mutableStateOf(null) }
SelectionContainer(selection = selection, onSelectionChange = { selection = it }) { … }
IIRC
l
Why don't we simply have a
EnableTextSelectionByDefault { … }
or alike wrapper if
Text
is no longer selectable by default? Having to declare a variable and configuring the thing isn't very intuitive to me
:)
🙂 2
l
Your snippet works, Zach (granted I import the getValue + setValue from compose runtime), but I see only the "Copy" option in the popup, no translate and all options… it's not invoking the text selection from the system?
Thank you Siyamed! Feel free to ping me if you're undecided about the naming 🙂
👍 1
s
It doesn't use system
It is not integrated to smart selection
If there is nothing to paste wont show paste
l
Is there a way to integrate it to system selection to get smart selection, translate and other niceties we got since Android 6?
2
Maybe something in the
onSelection
callback for the non smart selection related things?
BTW, I see that selection can cross components, like it's possible on webpages. That's very nice!
s
We will integrate, right now i am not aware of such away
👍 2