Interface

MouseInjectionScope

The receiver scope of the mouse input injection lambda from performMouseInput.

mouseInputClick

@Sampled
fun mouseInputClick() {
    composeTestRule.onNodeWithTag("myComponent").performMouseInput {
        // Click in the middle of the node
        click(center)
    }
}

mouseInputScrollWhileDown

@Sampled
fun mouseInputScrollWhileDown() {
    composeTestRule
        .onNodeWithTag("verticalScrollable")
        // Scroll downwards while keeping a button pressed:
        .performMouseInput {
            // Presses the primary mouse button
            press()
            // Scroll the scroll wheel by 6 units
            repeat(6) {
                advanceEventTime()
                scroll(1f)
            }
            // And release the mouse button
            advanceEventTime()
            release()
        }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: