-
Hello, I was making a ui module and had a problem creating text_box. I need to get the input value, but I'm Korean, so I'd like to input Korean as well. As a result of the search, I didn't understand exactly that you have to use Ime events to get languages other than English to enter, but I followed the example as much as I could. However, there was an issue where the event itself did not occur... pub fn ui_toggle_ime(
mut q_window: Query<&mut Window, With<PrimaryWindow>>,
focus: Res<TextBoxFocus>
){
let mut window = q_window.single_mut();
if focus.activity{
if !window.ime_enabled{
window.ime_enabled = true;
console::log_1(&JsValue::from_str(format!("ime enable {}", window.ime_enabled).as_str()));
window.ime_position = Vec2::new(window.width() / 2., window.height() / 2.);
}
}
else{
if window.ime_enabled{
window.ime_enabled = false;
console::log_1(&JsValue::from_str(format!("ime disable {}", window.ime_enabled).as_str()));
window.ime_position = Vec2::new(0., 0.);
}
}
}
///
...
///
pub fn ui_textbox_input(
mut query_text_box: Query<(&TextBox, &mut Text, Entity)>,
focus: Res<TextBoxFocus>,
mut input_key_event: EventReader<Ime>
){
let mut v = String::new();
for key in input_key_event.iter(){
match key {
Ime::Preedit {value, ..} => {
console::log_1(&JsValue::from_str(format!("buffer {}", value).as_str()));
},
Ime::Commit { value, .. } => {
console::log_1(&JsValue::from_str(format!("input {}", value).as_str()));
v.push_str(&value);
},
Ime::Enabled { ..} => {console::log_1(&JsValue::from_str(format!("ImeEnabled").as_str()));},
Ime::Disabled { ..} => {console::log_1(&JsValue::from_str(format!("ImeDisabled").as_str()));},
}
}
for (text_box, mut secction, entity) in query_text_box.iter_mut(){
if text_box.enable && focus.activity {
if focus.focus == entity{
let value = &mut secction.sections[0].value;
if value.len() < text_box.max_textsize{
console::log_1(&JsValue::from_str(format!("try input v {}", v.clone()).as_str()));
value.push_str(v.clone().as_str());
break;
}
}
}
}
} The ui_toggle_ime function works fine. However, the ui_textbox_input function does not have any events called into EventReader. I also printed out a log saying that the function is being performed to check if the function itself is occurring. Did I do something wrong? Thank you for reading anyway. Have a nice day |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I don't think that IME is implemented by winit for the web, unfortunately. I looked at the upcoming winit 0.29 release which is likely to be included in Bevy 0.12 and I think it is still unimplemented. |
Beta Was this translation helpful? Give feedback.
I don't think that IME is implemented by winit for the web, unfortunately.
I looked at the upcoming winit 0.29 release which is likely to be included in Bevy 0.12 and I think it is still unimplemented.