Crossterm: Not receiving mouse events

I'm trying to figure out how to capture mouse events with crossterm.

The program is pretty simple:

// shell: cargo add crossterm
use crossterm::event::read;

fn main() {
    loop {
        let new_event = read();
        println!("{:#?}", new_event.unwrap());
    }
}

This only seems to capture keyboard presses, after pressing enter, just because I haven't enabled "raw mode." Any time that I use the mouse wheel, or press a mouse button, I don't receive any events.

I've tried this on:

  • Windows Terminal
  • Wezterm (Windows)
  • Alacritty (Windows)
  • Konsole on Ubuntu Studio, via RDP

I've also tried adding in the non-default event-stream and use-dev-tty cargo features, just in case. That didn't help.

Question: Any ideas what is missing here? Why am I not receiving mouse button / scroll events?

Crossterm has a command to enable mouse capture. EnableMouseCapture in crossterm::event - Rust

std::io::stdout().execute(crossterm::event::EnableMouseCapture).unwrap();
2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.