Giter VIP home page Giter VIP logo

Comments (20)

xuerenlin avatar xuerenlin commented on May 30, 2024 1

Check if it works by applying egui Master Version.

It is expected that there will be no problems with the Master Version, and it will be corrected in the next egui Version (0.27.3 ?) update.

Thank you for your reply.

I test the master branch examples/hello_world:
1. In my window 11, it works good !!
2. But I test in ubuntu, the problem has not been resolved.

I modify crates/egui/src/widgets/text_edit/builder.rs like this, and it works.

            ImeEvent::Commit(prediction) => {
                println!("ImeEvent::Commit( {}", prediction);
                if prediction == "\n" || prediction == "\r" {
                    None
                } else {
                    state.ime_enabled = false;

                    if !prediction.is_empty()
                    //&& cursor_range.secondary.ccursor.index
                    //    == state.ime_cursor_range.secondary.ccursor.index
                    {
                        println!(
                            "cursor_range.secondary.ccursor.index:{}",
                            cursor_range.secondary.ccursor.index
                        );
                        println!(
                            "state.ime_cursor_range.secondary.ccursor.index:{}",
                            state.ime_cursor_range.secondary.ccursor.index
                        );

                        let mut ccursor = text.delete_selected(&cursor_range);
                        text.insert_text_at(&mut ccursor, prediction, char_limit);
                        Some(CCursorRange::one(ccursor))
                    } else {
                        let ccursor = cursor_range.primary.ccursor;
                        Some(CCursorRange::one(ccursor))
                    }
                }
            }

Then run this test, got the print below:

ImeEvent::Commit( **
cursor_range.secondary.ccursor.index:6
**state.ime_cursor_range.secondary.ccursor.index:0**
ImeEvent::Commit( 你好
cursor_range.secondary.ccursor.index:8
**state.ime_cursor_range.secondary.ccursor.index:0**

But I don't know why state.ime_cursor_range.secondary.ccursor.index is allway 0

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic

I test #4436 in Ubuntu.
The first time I entered "你好", it was not displayed in the text_edit box.
When I enter "你好" again, it's normal. Then every input is normal.
It looks like it's the first time that the control status is abnormal.

In text_edit/builder.rs fn events()

The First enter,get bellow ImeEvent:
ImeEvent::Commit: prediction=你好
ImeEvent::Disabled

The Second enter,get bellow ImeEvent:
ImeEvent::Enabled
ImeEvent::Commit: prediction=你好
ImeEvent::Disabled

The First enter, do not trigger ImeEvent::Enabled event.

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic

Test in Windows it works good,In text_edit/builder.rs fn events()
Every input get bellow ImeEvent:

  ImeEvent::Enabled
  ImeEvent::Enabled
  ImeEvent::Commit prediction=你好
  ImeEvent::Disabled
  ImeEvent::Disabled

The above tests used SougoPinyin(a popular IME in China).

Then I use MicrosoftPinyin(Windows default chinese IME) Test,get bellow ImeEvent:

  ImeEvent::Enabled
  ImeEvent::Preedit text_mark=n
  ImeEvent::Preedit text_mark=ni
  ImeEvent::Preedit text_mark=ni'h
  ImeEvent::Preedit text_mark=ni'ha
  ImeEvent::Preedit text_mark=ni'hao
  ImeEvent::Enabled
  ImeEvent::Commit prediction=你好
  ImeEvent::Disabled
  ImeEvent::Disabled

This result may be due to SougoPinyin not following the IME rules well?
And In Ubuntu system, I test GooglePinyin again, it has the same problem like SougoPinyin.

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@xuerenlin

Again, Please check if the following Pull Request has a problem in Ubuntu. If not, check if there is a problem in Windows as well and let us know the results.

Still #4436? I run "git pull" and test again, has the same problem.

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

crates/egui-winit/src/lib.rs 331 line, I add print:

WindowEvent::Ime(ime) => {
    println!("ime event is: {:?}", ime);

When app run, print:
ime event is: Enabled

Every time, I enter "你好", print:

ime event is: Preedit("", None)
ime event is: Commit("你好")

So total print information is:

ime event is: Enabled
ime event is: Preedit("", None)
ime event is: Commit("你好")
ime event is: Preedit("", None)
ime event is: Commit("你好")
ime event is: Preedit("", None)
ime event is: Commit("你好")
ime event is: Preedit("", None)
ime event is: Commit("你好")
ime event is: Preedit("", None)
ime event is: Commit("你好")

from egui.

rustbasic avatar rustbasic commented on May 30, 2024 1

This is the problem

When app run, print:
ime event is: Enabled

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic
I call ime_event_disable() once time, and it works.
Here is my test code:
image

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic

Yes, I change egui-winit/src/lib.rs, add call ime_event_disable() as follows:

                match ime {
                    winit::event::Ime::Enabled | winit::event::Ime::Preedit(_, None) => {
                        self.ime_event_enable();
                    }
                    winit::event::Ime::Preedit(text, Some(_cursor)) => {
                        self.ime_event_enable();
                        self.egui_input
                            .events
                            .push(egui::Event::Ime(egui::ImeEvent::Preedit(text.clone())));
                    }
                    winit::event::Ime::Commit(text) => {
                        self.egui_input
                            .events
                            .push(egui::Event::Ime(egui::ImeEvent::Commit(text.clone())));
                        self.ime_event_disable();
                    }
                    winit::event::Ime::Disabled => {
                        self.ime_event_disable();
                    }
                };
                ///////////////////////////////////////////////////////////////
                //following is my test code:
                static DISABLE_IME_ENABLE_AT_START: OnceLock<i32> = OnceLock::new();
                DISABLE_IME_ENABLE_AT_START.get_or_init(|| {
                    self.ime_event_disable();
                    println!("ime_event_disable");
                    return 0;
                });

You need to consider the specific solution. I'm just testing whether calling ime_event_disable() once when the program starts can solve the problem.

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic
Sorry, I have just been using egui for a few days and I am still not familiar with it. So I don't understand how to call ime_event_disable() in my program.
Is something can do in raw_input_hook() function ?

from egui.

rustbasic avatar rustbasic commented on May 30, 2024 1

@xuerenlin

Again,
Please check if the following Pull Request has a problem in Ubuntu and Windows.
Please test various IMEs.
let us know the results.

from egui.

xuerenlin avatar xuerenlin commented on May 30, 2024 1

@rustbasic
I tested the following scenarios and all of them worked properly !

  1. Windows + MicrosoftPinyin
  2. Windows + SougouPinyin
  3. Ubuntu + SougouPinyin
  4. Ubuntu + GooglePinyin

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

Check if it works by applying egui Master Version.

It is expected that there will be no problems with the Master Version,
and it will be corrected in the next egui Version (0.27.3 ?) update.

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Please check if the following Pull Request has a problem in Ubuntu. If not, check if there is a problem in Windows as well and let us know the results.

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Again,
Please check if the following Pull Request has a problem in Ubuntu. If not, check if there is a problem in Windows as well and let us know the results.

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Please print the winit::event::Ime:: event details at the following location and let us know.
I'll check tomorrow.

crates/egui-winit/src/lib.rs
330 line
WindowEvent::Ime(ime) => {

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

Because it is difficult to apply to all languages, there are no exact rules.
However, it is true that SougoPinyin has a unique behavior.

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Please check if it is possible as follows.
let me know result, please.

  1. Apply new #4436.

  2. Find a way to prevent winit::event::Ime::Enabled from occurring when the program starts.

OR

  1. Call ime_event_disable() in egui-winit/src/lib.rs only once when the program starts.
    (Alternatively, it is expected to operate normally even if you call ime_event_disable() every time before inputting.)

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Is it okay to call ime_event_disable() from your program without changing egui-winit/src/lib.rs?

Or is there anything I need to change in egui-winit/src/lib.rs to use ime_event_disable()?

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@xuerenlin

Do not modify egui-winit/src/lib.rs,
Make sure your program can call ime_event_disable().

Let's work together to get it in a usable condition.
Ultimately, approval from 'emilk' is required.

from egui.

rustbasic avatar rustbasic commented on May 30, 2024

@emilk @xuerenlin

I expect this to work, and we've been told it will work, so we hope this gets approved.

from egui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.