# gpui: Support hitbox blocking mouse interaction except scrolling \(\#31712\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/908678403871e0ef18bbe20f78a84654dfdd431d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 908678403871e0ef18bbe20f78a84654dfdd431d

Requested commit: 908678403871e0ef18bbe20f78a84654dfdd431d

Commit: 908678403871e0ef18bbe20f78a84654dfdd431d

Tree: 40d1a20517c127744df81fffafc139b610dc29b6

Author: Michael Sloan

Committer: GitHub

## Message

```
gpui: Support hitbox blocking mouse interaction except scrolling (#31712)

tl;dr: This adds `.block_mouse_except_scroll()` which should typically
be used instead of `.occlude()` for cases when the mouse shouldn't
interact with elements drawn below an element. The rationale for
treating scroll events differently:

* Mouse move / click / styles / tooltips are for elements the user is
interacting with directly.
* Mouse scroll events are about finding the current outer scroll
container.

Most use of `occlude` should probably be switched to this, but I figured
I'd derisk this change by minimizing behavior changes to just the 3 uses
of `block_mouse_except_scroll`.

GPUI changes:

* Added `InteractiveElement::block_mouse_except_scroll()`, and removes
`stop_mouse_events_except_scroll()`

* Added `Hitbox::should_handle_scroll()` to be used when handling scroll
wheel events.

* `Window::insert_hitbox` now takes `HitboxBehavior` instead of
`occlude: bool`.

    - `false` for that bool is now `HitboxBehavior::Normal`.

    - `true` for that bool is now `HitboxBehavior::BlockMouse`.
    
    - The new mode is `HitboxBehavior::BlockMouseExceptScroll`.

* Removes `Default` impl for `HitboxId` since applications should not
manually create `HitboxId(0)`.

Release Notes:

- N/A
```

## Parents

- [2abc5893c1495058a16c56c7c9e7544a0ead05fe](https://git.cafe/gitcafe/zed/commit/2abc5893c1495058a16c56c7c9e7544a0ead05fe?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/908678403871e0ef18bbe20f78a84654dfdd431d?format=markdown)
