-
Notifications
You must be signed in to change notification settings - Fork 1
Calculate relative y mouse event cursor position #11
Conversation
@zrzka can you check on macos/linux if the cursor positions from input events are relative to the current window or absolute to the current screen buffer. Otherwise, this patch is not needed to sync the behavior. But I am pretty convinced it was relative to the window... We better double-check. This PR should be merged before the release |
@TimonPost here's my test code ... use std::io::Write;
use crossterm_input::{input, InputEvent, KeyEvent, RawScreen, Result};
fn read_asynchronously() -> Result<()> {
let _raw = RawScreen::into_raw_mode()?;
let input = input();
input.enable_mouse_mode()?;
let mut stdin = input.read_async();
loop {
if let Some(key_event) = stdin.next() {
match key_event {
InputEvent::Keyboard(KeyEvent::Esc) => break,
InputEvent::Keyboard(KeyEvent::Up) => {
let mut stdout = std::io::stdout();
let _ = write!(stdout, "\x1B[5T");
let _ = stdout.flush();
}
InputEvent::Keyboard(KeyEvent::Down) => {
let mut stdout = std::io::stdout();
let _ = write!(stdout, "\x1B[5S");
let _ = stdout.flush();
}
ie => println!("\r{:?}", ie),
};
}
}
input.disable_mouse_mode()
}
fn main() -> Result<()> {
read_asynchronously()
} ... no matter how many times I hit |
Also there's no changelog entry, but for now, don't add it. Once you fix the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy :)
@TimonPost made more tests on Linux & macOS. Both behaves in the same way, top/left is 0,0 no matter how many times I scroll up/down. If you tested this on Windows, we can merge it. |
Fixes: crossterm-rs/crossterm#278
With patch:
TOP, LEFT click:
Previously:
TOP, LEFT click