# MouseScroll

`com.jsmacrosce.jsmacros.client.api.event.impl.EventMouseScroll`

**Since:** 1.9.0

**Cancellable:** Yes. Call `event.cancel()` in a handler before releasing the event lock.

Fires before the game handles a scroll input, only when no screen or overlay is open, a player is
present, and at least one raw offset is nonzero. The offsets have not yet been scaled by mouse
wheel sensitivity or converted by the discrete-scroll setting. Cancelling prevents the game's
scroll handling, including its input notification and gameplay effects.  
```js
JsMacros.on("MouseScroll", JavaWrapper.methodToJava(function (event) {
  if (event.deltaY > 0.0) {
    // positive is up, negative is down
    Chat.log(`scrolled up by ${event.deltaY}`);  
    event.cancel();  
  }
}))
```

## Constructors

### new EventMouseScroll {#com.jsmacrosce.jsmacros.client.api.event.impl.EventMouseScroll_constructor-double-double-}

```js
new EventMouseScroll(double deltaX, double deltaY)
```

Initializes the event with the supplied raw scroll offsets; construction does not dispatch it.

**Parameters:**
- `deltaX`: the horizontal scroll offset, stored unchanged
- `deltaY`: the vertical scroll offset, stored unchanged

## Fields

### deltaX {#com.jsmacrosce.jsmacros.client.api.event.impl.EventMouseScroll_deltaX}

```js
deltaX: double
```

Raw horizontal scroll offset from the windowing library, before game sensitivity or discrete-
scroll processing.

### deltaY {#com.jsmacrosce.jsmacros.client.api.event.impl.EventMouseScroll_deltaY}

```js
deltaY: double
```

Raw vertical scroll offset from the windowing library, before game sensitivity or discrete-
scroll processing.

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.EventMouseScroll_toString-}

```js
toString(): String
```

Returns a diagnostic string containing the event name and both scroll offsets.  
The result uses the format `%s:{"deltaX": %s, "deltaY": %s}`; it is not JSON, and
the offsets use `Double` string formatting without finite-value validation.

**Returns:** the event name and horizontal and vertical offsets in diagnostic form
