Dirk Hoffmann
10/23/2023, 2:07 PMBasicTextField
.
Everything works fine except, when I tap/click somewhere inside the TextField text, it (for sure) changes the position of the cursor,
but as no text change or layout change is happening to the TextField content, I cannot update my cursor position.
I have TextLayoutResult as a remembered state to get the new cursor rect via
TextLayoutResult.getCursorRect(textFieldValue.selection.end.coerceAtMost(layoutInput.text.length))
how can I get the cursor rect when I change it via "just clicking somewhere else" inside the TextFields text?Zach Klippenstein (he/him) [MOD]
10/23/2023, 4:42 PMTextFieldValue
overload to get the position of the cursor, then use the layout result to calculate its coordinatesDirk Hoffmann
10/23/2023, 5:25 PMTextFieldValue
???TextLayoutResult
(and not TextFieldValue) ... so (b) would be an ugly line like:
val cursorRect = textLayoutResult.value?.multiParagraph?.getCursorRect(textFieldValue.selection.end.coerceAtMost(textLayoutResult.value?.multiParagraph?.intrinsics?.annotatedString?.text?.length ?: 0).coerceAtLeast(0)) ?: Rect.Zero
println("cursorRect in onClick: $cursorRect")
leaves me with problem (a) I just don't get any click/tab working for BasicTextField
. Any ideas on that?? @Zach Klippenstein (he/him) [MOD]Zach Klippenstein (he/him) [MOD]
10/23/2023, 9:07 PMTextFieldValue
and observe it for selection changes. If you specifically only want to track clicks, then use TextFieldValue
and a pointerInput gesture to peek at pointer events.