Join Slack
I'm writing an ebook reader. I wrote a composable to display paginated text, which involves measurin...
# compose
d
Daniel
02/28/2021, 2:22 PM
I'm writing an ebook reader. I wrote a composable to display paginated text, which involves measuring MultiParagraphs and then rendering clipped portions to canvases. I want to allow text selection, so I looked at how the builtin Text handles selection. Unfortunately, essentially all the code used to manage selection in compose below the level of Text appears to be internal. I'm currently planning to copy
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]/foundation/text/selection/AndroidSelectionHandles.android.kt
and most of
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]l=78?q=CoreText&ss=androidx%2Fplatform%2Fframeworks%2Fsupport
to my own project, which doesn't feel ideal. Am I missing something?
j
jim
02/28/2021, 5:31 PM
cc
@Siyamed
d
Daniel
02/28/2021, 5:33 PM
Here's what I have so far:
https://gist.github.com/danielzfranklin/db21db2598a93294533764bcc4e6c5e8
Daniel
02/28/2021, 5:34 PM
I've got a
PageRenderer
that is responsible for knowing what text is on the current page where. All I'm doing is copying from what
CoreText
uses, stripping out anything I don't need (like cross-composable selection)
Daniel
02/28/2021, 5:35 PM
The gist leads to working drag-to-highlight so far
2
Views
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by