Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IME and CJK Support #120

Closed
stolen-programmer opened this issue Nov 28, 2023 · 3 comments
Closed

IME and CJK Support #120

stolen-programmer opened this issue Nov 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@stolen-programmer
Copy link
Contributor

native input method support is required

Need to input Chinese, Japanese, and Korean text

@stolen-programmer
Copy link
Contributor Author

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

@LPGhatguy LPGhatguy added the enhancement New feature or request label Nov 29, 2023
@stolen-programmer
Copy link
Contributor Author

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
}

@LPGhatguy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants