Capture double click mouse events (#826)

When double clicking on Windows, the crossterm_winapi emits the first
click with `EventFlags::PressOrRelease` and the second click with
`EventFlags::DoubleClick`. Previously this code explicitly ignored mouse
events with `EventFlags::DoubleClick` because "double click not
supported by unix terminals." This change captures the double click and
surfaces them as normal click events.
This commit is contained in:
Stephen Hunt 2024-01-06 04:01:07 -08:00 committed by GitHub
parent 6d6bed9c2c
commit cd1780c2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -314,7 +314,7 @@ fn parse_mouse_event_record(
let button_state = event.button_state;
let kind = match event.event_flags {
EventFlags::PressOrRelease => {
EventFlags::PressOrRelease | EventFlags::DoubleClick => {
if button_state.left_button() && !buttons_pressed.left {
Some(MouseEventKind::Down(MouseButton::Left))
} else if !button_state.left_button() && buttons_pressed.left {
@ -357,7 +357,6 @@ fn parse_mouse_event_record(
None
}
}
EventFlags::DoubleClick => None, // double click not supported by unix terminals
EventFlags::MouseHwheeled => {
if button_state.scroll_left() {
Some(MouseEventKind::ScrollLeft)