Given a BasicTextField2, somewhere in the compose ...
# compose
t
Given a BasicTextField2, somewhere in the compose tree, and it's currently focused, is it possible detect a tap/gesture anywhere outside of the text field? (I'd like to "cancel" edits at that point and clearFocus).
a
Surely. Gesture detection is unrelated to focus.
t
Yes, but I want to detect any other gesture through the whole UI. Would I need to place a root level component that did this, and somehow coordinate between that and my BTF2 somewhere within the hierarchy?
a
Here's how we are doing this. We get the rect of the text field and pass it to this modifier.
t
Thank you! To clarify, you're putting this modifier on a root component higher up the tree, and then using something like onGlobalPositioned on the TextField to track where it's at relative to the root component?
a
Right.
t
I know this is an old thread... I've been playing with the above. Do you find that you can still tap in the field and move the cursor around with your solution? I'm finding that I cannot. Keyboard input works fine, but can't seem to touch select the fields contents
a
I can.
t
Interesting. I've tried lots of variants of this. I can selectively manage the events, but once I place this on, no events will fall through to any components below it. I must be missing some other piece of configuration or something.