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:
parent
6d6bed9c2c
commit
cd1780c2d8
@ -314,7 +314,7 @@ fn parse_mouse_event_record(
|
|||||||
let button_state = event.button_state;
|
let button_state = event.button_state;
|
||||||
|
|
||||||
let kind = match event.event_flags {
|
let kind = match event.event_flags {
|
||||||
EventFlags::PressOrRelease => {
|
EventFlags::PressOrRelease | EventFlags::DoubleClick => {
|
||||||
if button_state.left_button() && !buttons_pressed.left {
|
if button_state.left_button() && !buttons_pressed.left {
|
||||||
Some(MouseEventKind::Down(MouseButton::Left))
|
Some(MouseEventKind::Down(MouseButton::Left))
|
||||||
} else if !button_state.left_button() && buttons_pressed.left {
|
} else if !button_state.left_button() && buttons_pressed.left {
|
||||||
@ -357,7 +357,6 @@ fn parse_mouse_event_record(
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventFlags::DoubleClick => None, // double click not supported by unix terminals
|
|
||||||
EventFlags::MouseHwheeled => {
|
EventFlags::MouseHwheeled => {
|
||||||
if button_state.scroll_left() {
|
if button_state.scroll_left() {
|
||||||
Some(MouseEventKind::ScrollLeft)
|
Some(MouseEventKind::ScrollLeft)
|
||||||
|
Loading…
Reference in New Issue
Block a user