# MouseInjectionScope

Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+class:androidx.compose.ui.test.MouseInjectionScope) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface MouseInjectionScope : InjectionScope
  ```

*** ** * ** ***

The receiver scope of the mouse input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)`.

The functions in `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope` can roughly be divided into two groups: full gestures and individual mouse events. The individual mouse events are: `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` and friends, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#cancel(kotlin.Long)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#advanceEventTime(kotlin.Long)`. Full gestures are all the other functions, like `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)`, etc. These are built on top of the individual events and serve as a good example on how you can build your own full gesture functions.

A mouse move event can be sent with `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)`. The mouse position can be updated with `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerBy(androidx.compose.ui.geometry.Offset)`, which will not send an event and only update the position internally. This can be useful if you want to send an event that is not a move event with a location other then the current location, but without sending a preceding move event. Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)` to send button pressed and button released events. This will also send all other necessary events that keep the stream of mouse events consistent with actual mouse input, such as a hover exit event. A `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#cancel(kotlin.Long)` event can be sent at any time when at least one button is pressed. Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` to send a mouse scroll event.

The entire event injection state is shared between all `perform.*Input` methods, meaning you can continue an unfinished mouse gesture in a subsequent invocation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMultiModalInput(kotlin.Function1)`. Note however that while the mouse's position is retained across invocation of `perform.*Input` methods, it is always manipulated in the current node's local coordinate system. That means that two subsequent invocations of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)` on different nodes will report a different `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()`, even though it is actually the same position on the screen.

All events sent by these methods are batched together and sent as a whole after `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)` has executed its code block.

Example of performing a mouse click:

```kotlin
import androidx.compose.ui.test.click
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

composeTestRule.onNodeWithTag("myComponent").performMouseInput {
    // Click in the middle of the node
    click(center)
}
```

Example of scrolling the mouse wheel while the mouse button is pressed:

```kotlin
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

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()
    }
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope` |   |

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#cancel(kotlin.Long)(delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sends a cancel event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#cancel(kotlin.Long)` after the last sent event to cancel a stream of mouse events with pressed mouse buttons. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sends a hover enter event at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event, without sending a hover move event. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sends a hover exit event at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event, without sending a hover move event. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)(delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sends a move event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event on the associated node, with the position of the mouse moved by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sends a move event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event on the associated node, with the position of the mouse updated to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)(button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Sends a down and button pressed event for the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` on the associated node. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)(button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Sends a button released and up event for the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)` on the associated node. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(androidx.compose.ui.geometry.Offset)(offset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Sends a scroll event with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(androidx.compose.ui.geometry.Offset)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, scrollWheel: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel)` Sends a scroll event with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` on the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerBy(androidx.compose.ui.geometry.Offset)(delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Updates the position of the mouse by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerBy(androidx.compose.ui.geometry.Offset)`, but does not send a move or hover event. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Updates the position of the mouse to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)`, but does not send a move or hover event. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` Returns the current position of the mouse. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)( curve: (timeMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) -> https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Move the mouse along the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)` milliseconds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).animateMoveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)(delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Move the mouse from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)` milliseconds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)( position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Move the mouse from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` milliseconds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to double-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)( start: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, end: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` to drag and drop something from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` in `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` milliseconds. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to long-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset)` Secondary-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)( scrollAmount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, scrollWheel: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel )` Rotate the mouse's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)` by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)(position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton)` Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to triple-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. | Cmn |

### Inherited functions

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).roundToPx()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).roundToPx()()`

Convert Sp to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toDp()()`

Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toDp()()`

Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Dp
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.geometry.Size).toDpSize()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize`.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).toPx()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to pixels.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).toPx()()`

Convert Sp to pixels.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpRect).toRect()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpSize).toSize()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toSp()()`

Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to Sp.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toSp()()`

Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Sp
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.TextUnit).toDp()()`

Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.Dp).toSp()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp.
Cmn From [androidx.compose.ui.test.InjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#advanceEventTime(kotlin.Long)(durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Adds the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#advanceEventTime(kotlin.Long)` to the current event time, delaying the next event by that time.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#percentOffset(kotlin.Float,kotlin.Float)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Creates an `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` relative to the size of the node we're interacting with.
Cmn

### Inherited properties

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#density()`

The logical density of the display.
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#fontScale()`

Current user preference for the scaling factor for fonts.
Cmn From [androidx.compose.ui.test.InjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottom()`

The y-coordinate for the bottom of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomCenter()`

The center of the bottom edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomLeft()`

The bottom left corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#bottomRight()`

The bottom right corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()`

The center of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerLeft()`

The center of the left edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerRight()`

The center of the right edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerX()`

The x-coordinate for the center of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#centerY()`

The y-coordinate for the center of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()`

The default time between two successive events.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#height()`

The height of the node in px.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#left()`

The x-coordinate for the left edge of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#right()`

The x-coordinate for the right edge of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#top()`

The y-coordinate for the top of the node we're interacting with in px, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topCenter()`

The center of the top edge of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topLeft()`

The top left corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#topRight()`

The top right corner of the node we're interacting with, in the node's local coordinate system, where (0, 0) is the top left corner of the node.
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewConfiguration` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#viewConfiguration()`

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewConfiguration` in use by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsNode` from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction` on which the input injection method is called.
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#visibleSize()`

The size of the visible part of the node we're interacting with in px, i.e. its clipped bounds.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#width()`

The width of the node in px.
Cmn

## Public functions

### cancel

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
fun cancel(delayMillis: Long = eventPeriodMillis): Unit
```

Sends a cancel event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#cancel(kotlin.Long)` after the last sent event to cancel a stream of mouse events with pressed mouse buttons. All buttons will be released as a result. A mouse cancel event can only be sent when mouse buttons are pressed.

| Parameters |
|---|---|
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = eventPeriodMillis` | The time between the last sent event and this event. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` by default. |

### enter

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun enter(
    position: Offset = currentPosition,
    delayMillis: Long = eventPeriodMillis
): Unit
```

Sends a hover enter event at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event, without sending a hover move event.

An `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` will be thrown when mouse buttons are down, or if the mouse is already hovering.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#enter(androidx.compose.ui.geometry.Offset,kotlin.Long)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

**Note** : enter and exit events are already sent as a side effect of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` when necessary. Whether or not this is part of the contract of mouse events is platform dependent, so it is highly discouraged to manually send enter or exit events. Only use this method for tests that need to make assertions about a component's state *in between* the enter/exit and move event.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = currentPosition` | The new position of the mouse, in the node's local coordinate system. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` by default. |
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = eventPeriodMillis` | The time between the last sent event and this event. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` by default. |

### exit

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun exit(position: Offset = currentPosition, delayMillis: Long = eventPeriodMillis): Unit
```

Sends a hover exit event at the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event, without sending a hover move event.

An `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` will be thrown if the mouse was not hovering.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#exit(androidx.compose.ui.geometry.Offset,kotlin.Long)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

**Note** : enter and exit events are already sent as a side effect of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` when necessary. Whether or not this is part of the contract of mouse events is platform dependent, so it is highly discouraged to manually send enter or exit events. Only use this method for tests that need to make assertions about a component's state *in between* the enter/exit and move event.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = currentPosition` | The new position of the mouse, in the node's local coordinate system `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` by default. |
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = eventPeriodMillis` | The time between the last sent event and this event. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` by default. |

### moveBy

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
open fun moveBy(delta: Offset, delayMillis: Long = eventPeriodMillis): Unit
```

Sends a move event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event on the associated node, with the position of the mouse moved by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)`.

If no mouse buttons are pressed, a hover event will be sent instead of a move event. If the mouse wasn't hovering yet, a hover enter event is sent as well.

| Parameters |
|---|---|
| `delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position for this move event, relative to the current position of the mouse. For example, \`delta = Offset(10.px, -10.px) will add 10.px to the mouse's x-position, and subtract 10.px from the mouse's y-position. |
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = eventPeriodMillis` | The time between the last sent event and this event. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` by default. |

### moveTo

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun moveTo(position: Offset, delayMillis: Long = eventPeriodMillis): Unit
```

Sends a move event `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` after the last sent event on the associated node, with the position of the mouse updated to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)`. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

If no mouse buttons are pressed, a hover event will be sent instead of a move event. If the mouse wasn't hovering yet, a hover enter event is sent as well.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The new position of the mouse, in the node's local coordinate system |
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = eventPeriodMillis` | The time between the last sent event and this event. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#eventPeriodMillis()` by default. |

### press

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun press(button: MouseButton = MouseButton.Primary): Unit
```

Sends a down and button pressed event for the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` on the associated node. When no buttons were down yet, this will exit hovering mode before the button is pressed. All events will be sent at the current event time.

Throws an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` if the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` is already pressed.

| Parameters |
|---|---|
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The mouse button that is pressed. By default the primary mouse button. |

### release

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun release(button: MouseButton = MouseButton.Primary): Unit
```

Sends a button released and up event for the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)` on the associated node. If this was the last button to be released, the mouse will enter hovering mode and send an accompanying mouse move event after the button has been released. All events will be sent at the current event time.

Throws an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` if the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#release(androidx.compose.ui.test.MouseButton)` is not pressed.

| Parameters |
|---|---|
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The mouse button that is released. By default the primary mouse button. |

### scroll

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
open fun scroll(offset: Offset): Unit
```

Sends a scroll event with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(androidx.compose.ui.geometry.Offset)`. The event will be sent at the current event time.

This is a 2 dimensional version of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(androidx.compose.ui.geometry.Offset)` and therefore will apply to a 2d plane. It combines the delta and the scrollWheel directionality in a single offset representation. A positive X component implies moving forward on the horizontal axis. A positive Y component implies moving forward on the vertical axis. A negative component means moving backwards. A combination of positive and negative components will yield an angled movement in a given quadrant of the 2d plane. For instance, moving with offset (100, -100) will move on the equivalent of 100 pixels forward on the horizontal axis and 100 pixels backward on the vertical axis.

Note that the correlation between scroll `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(androidx.compose.ui.geometry.Offset)` and pixels scrolled is platform specific. For example, on Android a scroll delta of `1f` corresponds to a scroll of `64.dp`. However, on any platform, this conversion factor could change in the future to improve the mouse scroll experience.

Example of how scroll could be used:

```kotlin
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

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()
    }
```

| Parameters |
|---|---|
| `offset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The amount of scroll |

### scroll

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun scroll(delta: Float, scrollWheel: ScrollWheel = ScrollWheel.Vertical): Unit
```

Sends a scroll event with the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` on the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)`. The event will be sent at the current event time.

Positive `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` values correspond to scrolling forward (new content appears at the bottom of a column, or at the end of a row), negative values correspond to scrolling backward (new content appears at the top of a column, or at the start of a row).

Note that the correlation between scroll `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` and pixels scrolled is platform specific. For example, on Android a scroll delta of `1f` corresponds to a scroll of `64.dp`. However, on any platform, this conversion factor could change in the future to improve the mouse scroll experience.

Example of how scroll could be used:

```kotlin
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

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()
    }
```

| Parameters |
|---|---|
| `delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount of scroll |
| `scrollWheel: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel = ScrollWheel.Vertical` | Which scroll wheel to rotate. Can be either `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel#Vertical()` (the default) or `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel#Horizontal()`. |

### updatePointerBy

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
open fun updatePointerBy(delta: Offset): Unit
```

Updates the position of the mouse by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerBy(androidx.compose.ui.geometry.Offset)`, but does not send a move or hover event. This can be useful to adjust the mouse position before sending for example a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` event.

| Parameters |
|---|---|
| `delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position for this move event, relative to the current position of the mouse. For example, \`delta = Offset(10.px, -10.px) will add 10.px to the mouse's x-position, and subtract 10.px from the mouse's y-position. |

### updatePointerTo

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun updatePointerTo(position: Offset): Unit
```

Updates the position of the mouse to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)`, but does not send a move or hover event. This can be useful to adjust the mouse position before sending for example a `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#press(androidx.compose.ui.test.MouseButton)` event. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)` is in the node's local coordinate system, where (0.px, 0.px) is the top left corner of the node.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The new position of the mouse, in the node's local coordinate system |

## Public properties

### currentPosition

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
val currentPosition: Offset
```

Returns the current position of the mouse. The position is returned in the local coordinate system of the node with which we're interacting. (0, 0) is the top left corner of the node. If none of the move or updatePointer methods have been used yet, the mouse's position will be (0, 0) in the Compose host's coordinate system, which will be `-[topLeft]` in the node's local coordinate system.

## Extension functions

### MouseInjectionScope.animateMoveAlong

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:animateMoveAlong)

```
fun MouseInjectionScope.animateMoveAlong(
    curve: (timeMillis: Long) -> Offset,
    durationMillis: Long = DefaultMouseGestureDurationMillis
): Unit
```

Move the mouse along the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)` milliseconds. The mouse will initially be moved to the start of the path, `curve(0)`, if it is not already there. The positions defined by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveAlong(kotlin.Function1,kotlin.Long)` are in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Example of moving the mouse along a curve:

```kotlin
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.test.animateMoveAlong
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

composeTestRule.onNodeWithTag("myComponent").performMouseInput {
    // Hover over the node, making a full circle with a radius of 100px
    val r = 100f
    animateMoveAlong(
        curve = {
            val angle = 2 * PI * it / 1000
            center + Offset(r * cos(angle).toFloat(), r * sin(angle).toFloat())
        },
        durationMillis = 1000L,
    )
}
```

| Parameters |
|---|---|
| `curve: (timeMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) -> https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The function that defines the position of the mouse over time for this gesture, in the node's local coordinate system. The argument passed to the function is the time in milliseconds since the start of the animated move, and the return value is the location of the mouse at that point in time |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = DefaultMouseGestureDurationMillis` | The duration of the gesture. By default 300 milliseconds. |

### MouseInjectionScope.animateMoveBy

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:animateMoveBy)

```
fun MouseInjectionScope.animateMoveBy(
    delta: Offset,
    durationMillis: Long = DefaultMouseGestureDurationMillis
): Unit
```

Move the mouse from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveBy(androidx.compose.ui.geometry.Offset,kotlin.Long)` milliseconds.

| Parameters |
|---|---|
| `delta: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position where to move the mouse to, relative to the current position of the mouse. For example, \`delta = Offset(100.px, -100.px) will move the mouse 100 pixels to the right and 100 pixels upwards. |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = DefaultMouseGestureDurationMillis` | The duration of the gesture. By default 300 milliseconds. |

### MouseInjectionScope.animateMoveTo

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:animateMoveTo)

```
fun MouseInjectionScope.animateMoveTo(
    position: Offset,
    durationMillis: Long = DefaultMouseGestureDurationMillis
): Unit
```

Move the mouse from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#currentPosition()` to the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)`, sending a stream of move events to get an animated path of `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` milliseconds. `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#moveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` the mouse to the desired start position if you want to start from a different position. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).animateMoveTo(androidx.compose.ui.geometry.Offset,kotlin.Long)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

Example of moving the mouse along a line:

```kotlin
import androidx.compose.ui.test.animateMoveTo
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput

composeTestRule.onNodeWithTag("myComponent").performMouseInput {
    // Hover over the node, making an X shape
    moveTo(topLeft)
    animateMoveTo(bottomRight)
    // Note that an actual user wouldn't be able to instantly
    // move from the bottom right to the top right
    advanceEventTime()
    moveTo(topRight)
    animateMoveTo(bottomLeft)
}
```

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position where to move the mouse to, in the node's local coordinate system |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = DefaultMouseGestureDurationMillis` | The duration of the gesture. By default 300 milliseconds. |

### MouseInjectionScope.click

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:click)

```
fun MouseInjectionScope.click(
    position: Offset = center,
    button: MouseButton = MouseButton.Primary
): Unit
```

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node. The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).click(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` button. There is a small 60ms delay between the press and release events to have a realistic simulation.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The position where to click, in the node's local coordinate system. If omitted, the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` of the node will be used. If `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`, clicks on the current mouse position. |
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The button to click with. Uses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` by default. |

### MouseInjectionScope.doubleClick

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:doubleClick)

```
fun MouseInjectionScope.doubleClick(
    position: Offset = center,
    button: MouseButton = MouseButton.Primary
): Unit
```

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to double-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node. The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).doubleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` button.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The position where to click, in the node's local coordinate system. If omitted, the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` of the node will be used. If `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`, clicks on the current mouse position. |
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The button to click with. Uses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` by default. |

### MouseInjectionScope.dragAndDrop

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:dragAndDrop)

```
fun MouseInjectionScope.dragAndDrop(
    start: Offset,
    end: Offset,
    button: MouseButton = MouseButton.Primary,
    durationMillis: Long = DefaultMouseGestureDurationMillis
): Unit
```

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` to drag and drop something from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` in `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` milliseconds. The mouse position is `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#updatePointerTo(androidx.compose.ui.geometry.Offset)` to the start position before starting the gesture. The positions defined by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).dragAndDrop(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton,kotlin.Long)` are in the node's local coordinate system, where (0, 0) is the top left corner of the node.

| Parameters |
|---|---|
| `start: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position where to press the primary mouse button and initiate the drag, in the node's local coordinate system. |
| `end: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | The position where to release the primary mouse button and end the drag, in the node's local coordinate system. |
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The button to drag with. Uses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` by default. |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = DefaultMouseGestureDurationMillis` | The duration of the gesture. By default 300 milliseconds. |

### MouseInjectionScope.longClick

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:longClick)

```
fun MouseInjectionScope.longClick(
    position: Offset = center,
    button: MouseButton = MouseButton.Primary
): Unit
```

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to long-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node. The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).longClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` button.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The position where to click, in the node's local coordinate system. If omitted, the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` of the node will be used. If `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`, clicks on the current mouse position. |
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The button to click with. Uses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` by default. |

### MouseInjectionScope.rightClick

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:rightClick)

```
fun MouseInjectionScope.rightClick(position: Offset = center): Unit
```

Secondary-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. While the secondary mouse button is not necessarily the right mouse button (e.g. on left-handed mice), this method is still called `rightClick` for it's widespread use. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).rightClick(androidx.compose.ui.geometry.Offset)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The position where to click, in the node's local coordinate system. If omitted, the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` of the node will be used. If `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`, clicks on the current mouse position. |

### MouseInjectionScope.smoothScroll

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:smoothScroll)

```
fun MouseInjectionScope.smoothScroll(
    scrollAmount: Float,
    durationMillis: Long = DefaultMouseGestureDurationMillis,
    scrollWheel: ScrollWheel = ScrollWheel.Vertical
): Unit
```

Rotate the mouse's `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)` by the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)`. The total scroll delta is linearly smoothed out over a stream of scroll events between each scroll event.

Positive `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)` values correspond to scrolling forward (new content appears at the bottom of a column, or at the end of a row), negative values correspond to scrolling backward (new content appears at the top of a column, or at the start of a row).

Example of a horizontal smooth scroll:

```kotlin
import androidx.compose.ui.test.ScrollWheel
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performMouseInput
import androidx.compose.ui.test.smoothScroll

composeTestRule.onNodeWithTag("horizontalScrollable").performMouseInput {
    // Scroll forwards horizontally, which is rightwards
    // unless scroll direction is reversed
    smoothScroll(100f, durationMillis = 500L, ScrollWheel.Horizontal)
    // The 100f scroll delta is equally divided into smaller scrolls,
    // such that the time in between two scroll events is more or less
    // equal to the default time between events, 16ms.
}
```

| Parameters |
|---|---|
| `scrollAmount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The total delta to scroll the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).smoothScroll(kotlin.Float,kotlin.Long,androidx.compose.ui.test.ScrollWheel)` by |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = DefaultMouseGestureDurationMillis` | The duration of the gesture. By default 300 milliseconds. |
| `scrollWheel: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel = ScrollWheel.Vertical` | Which scroll wheel will be rotated. By default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/ScrollWheel#Vertical()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope#scroll(kotlin.Float,androidx.compose.ui.test.ScrollWheel)` |   |

### MouseInjectionScope.tripleClick

Cmn Artifact: [androidx.compose.ui:ui-test](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/test/MouseInjectionScope.kt+function:tripleClick)

```
fun MouseInjectionScope.tripleClick(
    position: Offset = center,
    button: MouseButton = MouseButton.Primary
): Unit
```

Use `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` to triple-click on `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)`, or on the current mouse position if `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is in the node's local coordinate system, where (0, 0) is the top left corner of the node. The default `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.MouseInjectionScope).tripleClick(androidx.compose.ui.geometry.Offset,androidx.compose.ui.test.MouseButton)` is the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` button.

| Parameters |
|---|---|
| `position: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = center` | The position where to click, in the node's local coordinate system. If omitted, the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope#center()` of the node will be used. If `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()`, clicks on the current mouse position. |
| `button: https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton = MouseButton.Primary` | The button to click with. Uses the `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseButton#Primary()` by default. |