https://kotlinlang.org logo
#compose
Title
# compose
d

Daniel

03/02/2021, 11:48 PM
Can I detect taps outside of a component? I want to have a dropdown collapse itself on tap outside of it, without needed to require every parent to listen for tap events and tell it to close
z

zoha131

03/03/2021, 12:12 AM
You can use 'DropDown' composable for this usecase
d

Daniel

03/03/2021, 12:14 AM
Are you talking about DropDownMenu? If so, that's what I'm wrapping. I'm finding it quite finicky
l

Louis Pullen-Freilich [G]

03/03/2021, 12:23 AM
DropDownMenu
already should dismiss when you tap outside. Are you setting
expanded
to false in
onDismissRequest
?
d

Daniel

03/03/2021, 12:34 AM
I was asking because I've needed to do this other places and assumed I'd need to do it for DropDownMenu as well
I actually haven't managed to get DropDownMenu to display anything to the screen yet @Louis Pullen-Freilich [G]
Nevermind, the issue was the DropDownMenu doesn't show up in the preview
l

Louis Pullen-Freilich [G]

03/03/2021, 12:39 AM
Ah yeah, DropDownMenu is a popup window, and I think popup windows and dialogs don't yet show up in the preview
2 Views