obv-mikhail / InputBot

Rust library for creating global hotkeys, and simulating inputs
MIT License
421 stars 74 forks source link

graceful way to end `inputbot::handle_input_events` #80

Closed Redhawk18 closed 1 year ago

Redhawk18 commented 1 year ago

Hi I'm building a gui around this crate, and I enjoy using it. Currently I start handle_input_events in a new thread so my gui doesn't freeze, and there's no correct way to end this loop. I could kill the thread but that seems wrong. I'd be open to submitting a pr if i could get some information on what is needed since every platform has a different impl of handle_input_events.

obv-mikhail commented 1 year ago

Feel free to implement a solution just for the platform you are working on. Maybe a new function called stop_handling_input_events could be made?

Redhawk18 commented 1 year ago

is there a preferred way to stop the loop? the only thing i can think of is a global variable and adding

pub fn handle_input_events() {
  if stop { return }
...
}

pub fn stop_handling_input_events() {
  stop = true
  }
obv-mikhail commented 1 year ago

Sure, something of that nature seems fine.