gyscos / gyscos/cursive

[BUG] Form elements (e.g. `Checkbox`) take focus on scroll

Open
#649 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
4.8k
Forks
270
Avg merge
5d 19h
Merged PRs (30d)
2

Description

**Describe the bug**

When trying to scroll, if the mouse is over an element like a `Checkbox`, instead of scrolling in the parent view, focus is moved to that element.

**To Reproduce**

Reproduces in `cargo run --example list_view`. Move your mouse over the checkbox, and then scroll. The checkbox takes focus. Actually, the issue reproduces for all of the form controls — I don't want any of them to be taking focus in this situation

**Expected behavior**

The containing `ScrollView` should scroll.

**Environment**
* Operating system used: macOS
* Backend used: `crossterm`
* Current locale:
```
* LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
```

* Cursive version (from crates.io, from git, ...) 0c6669d6732c3cffeda983958bd9a0fe05ac3b44

**Additional context**

I tried adjusting `take_focus` as follows:

```
fn take_focus(&mut self, direction: Direction) -> Result {
match direction {
Direction::Abs(Absolute::None) => Ok(EventResult::Ignored),
_ => self.enabled.then(EventResult::consumed).ok_or(CannotFocus),
}
}
```

Of course, this means that the element no longer responds to mouse click events, which is also not desirable. Is there any workaround to make these elements respond to clicks but not scrolls?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.