Skip to content

Commit

Permalink
Fix text input events
Browse files Browse the repository at this point in the history
  • Loading branch information
17cupsofcoffee committed Dec 2, 2024
1 parent 52e820d commit 1773d02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/input/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl Event {
let text = std::ffi::CStr::from_ptr(event.text.text)
.to_string_lossy()
.into_owned();

return Some(Event::TextInput { text });
}

Expand Down
13 changes: 13 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use sdl3_sys::error::*;
use sdl3_sys::events::*;
use sdl3_sys::init::*;
use sdl3_sys::keyboard::*;
use sdl3_sys::version::*;
use sdl3_sys::video::*;

Expand Down Expand Up @@ -133,6 +134,18 @@ impl Window {
SDL_SetWindowTitle(self.window, c_title.as_ptr());
}
}

pub fn start_text_input(&mut self) {
unsafe {
SDL_StartTextInput(self.window);
}
}

pub fn stop_text_input(&mut self) {
unsafe {
SDL_StopTextInput(self.window);
}
}
}

impl Drop for Window {
Expand Down

0 comments on commit 1773d02

Please sign in to comment.