Skip to content

Commit

Permalink
Capture double click mouse events (#826)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stphnt committed Jan 6, 2024
1 parent 6d6bed9 commit cd1780c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/event/sys/windows/parse.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cd1780c

Please sign in to comment.