adjpd
09/08/2021, 10:42 PMDialog
and DropDownMenu
unexpand and hide, respectively, when the user touches outside the composables.
How can I implement this myself? I want to hide a composable if the user touches outside the composable.adjpd
09/08/2021, 11:11 PMAbstractComposeView
so I can get access to onTouchEvent
and check if the click is within the composable.
Is there an easier way? It feels rather heavyweight to use an AbstractComposeView
rather than the usual compose coding style for something fairly simple.Alexandre Elias [G]
09/09/2021, 6:19 PMModifier.pointerInput
for this. I suggest imitating the Scrim pattern in the built-in `ModalDrawer`: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]otlin/androidx/compose/material/Drawer.kt;l=374?q=ModalDraweradjpd
09/09/2021, 8:05 PMAlexandre Elias [G]
09/09/2021, 8:39 PMModifier.pointerInput
listener instead of a Modifier.clickable
because the latter is designed for things like buttons, and will have undesirable effects on screen reader accessibilityadjpd
09/09/2021, 9:52 PMAlexandre Elias [G]
09/09/2021, 10:01 PMModalDrawer
is written in a such a way to take priority over the children (scrim as peer to content lambda instead of parent), I recommend imitating it.adjpd
09/09/2021, 10:25 PMModalDrawer
, isn't on the root level with the other composables. So I'm unsure if this will work.adjpd
09/09/2021, 10:31 PM.semantics(mergeDescendants = true) {
contentDescription = closeDrawer
onClick { onClose(); true }
}
Alexandre Elias [G]
09/09/2021, 10:38 PMadjpd
09/09/2021, 10:43 PMscrims
clicks my fall through the other composables but since that isn't the case, I assume, with ModalDrawer
I guess it will work. Thanks Alexandre for your time. Hopefully I'll have a decent solution soon.adjpd
09/09/2021, 11:00 PMDropDownMenu
manages to do this with a AbstractComposeView
(here precisely) but getting AbstractComposeView
to work within a Compose
project, rather than from the Android view system, is a new adventure...