Closed stolen-programmer closed 11 months ago
use yakui::widgets::{Pad, TextBox};
use yakui::{center, use_state};
pub fn run() {
let text = use_state(|| "".to_owned());
center(|| {
let mut my_box = TextBox::new(text.borrow().as_str());
my_box.style.font = "MSYH".into();
my_box.style.font_size = 60.0;
my_box.padding = Pad::all(50.0);
my_box.placeholder = "你好".into();
let response = my_box.show().into_inner();
if let Some(new_text) = response.text {
text.set(format!("你好世界{}", new_text));
}
if response.activated {
println!("{}", text.borrow());
}
});
}
fn main() {
bootstrap::start(run as fn());
}
At present, it can be confirmed that the display is normal, but the Chinese input method cannot be switched
window.set_ime_allowed(true);
/// yakui/crates/yakui-winit/src/lib.rs
WinitEvent::WindowEvent {
event: WindowEvent::Ime(winit::event::Ime::Commit(text)),
..
} => {
for c in text.chars() {
state.handle_event(Event::TextInput(c));
}
true
}
Thank you for the PR on this! I did some testing after I merged your PR. I filed issues #122, #123, and #124 with specific things that we still need to make our IME support good.
native input method support is required
Need to input Chinese, Japanese, and Korean text