Add offset coordinates to mouse events on TUI and desktop.

This commit is contained in:
Reinis Mazeiks committed 2022-05-04 16:42:14 +03:00
1 parent 96c178f91f
commit d84d414170
3 files changed
+14

No files matched your search

+6
View File
@@ -602,6 +602,10 @@ fn get_event(evt: TermEvent) -> Option<(&'static str, EventData)> {
Some(MouseButton::Right) => 2,
};
// from https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
// The `offset`, `page` and `screen` coordinates are inconsistent with the MDN definition, as they are relative to the viewport (client), not the target element/page/screen, respectively.
// todo?
// But then, MDN defines them in terms of pixels, yet crossterm provides only row/column, and it might not be possible to get pixels. So we can't get 100% consistency anyway.
EventData::Mouse(MouseData {
alt_key: alt,
button: button_state,
@@ -610,6 +614,8 @@ fn get_event(evt: TermEvent) -> Option<(&'static str, EventData)> {
client_y: y,
ctrl_key: ctrl,
meta_key: meta,
offset_x: x,
offset_y: y,
page_x: x,
page_y: y,
screen_x: x,