Skip to content

Commit

Permalink
feat(ime): add Input Method Support (#121)
Browse files Browse the repository at this point in the history
Co-authored-by: juvenile <[email protected]>
  • Loading branch information
stolen-programmer and juvenile authored Dec 1, 2023
1 parent b3435af commit 9604132
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ async fn run(body: impl ExampleBody) {
.build(&event_loop)
.unwrap();

window.set_ime_allowed(true);

// yakui_app has a helper for setting up winit and wgpu.
let mut app = yakui_app::Graphics::new(&window).await;

Expand Down Expand Up @@ -124,6 +126,7 @@ async fn run(body: impl ExampleBody) {
FontSettings::default(),
)
.unwrap();

fonts.add(font, Some("monospace"));

// Set up some default state that we'll modify later.
Expand Down
10 changes: 10 additions & 0 deletions crates/yakui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ impl YakuiWinit {
false
}
}

WinitEvent::WindowEvent {
event: WindowEvent::Ime(winit::event::Ime::Commit(text)),
..
} => {
for c in text.chars() {
state.handle_event(Event::TextInput(c));
}
true
}
_ => false,
}
}
Expand Down

0 comments on commit 9604132

Please sign in to comment.