Search code examples
androidaccessibilityandroid-jetpack-compose

How to disable talkback action on a clickable composable item


I have a composable function that displays some text. The talkback is working great as it reads the text. but how can I disable the clickable notification in accessibility for that composable so that I can have a secret click listener to send analytics.

any time I try to add a clickable like this

Column(
        modifier = Modifier.fillMaxWidth().clickable { 
                                                     
        },
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
    )

When this column is on focus it says 'Double click to activate', and I want to avoid that as there is no user-facing feature on that click.


Solution

  • As described in the accessibility doc you can use the semantics properties. Use the invisibleToUser property to mark an element to be invisible to the user.

    Column(
        modifier = Modifier.semantics {
            this.invisibleToUser()}
    ){}