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

Embedded web page text box can not input Chinese in CefSharp.WPF #1777

Closed
mayuxian opened this issue Aug 22, 2016 · 4 comments
Closed

Embedded web page text box can not input Chinese in CefSharp.WPF #1777

mayuxian opened this issue Aug 22, 2016 · 4 comments

Comments

@mayuxian
Copy link

Bug Report

Delete this line and everything above, and then fill in the details below.

  • What version of the product are you using?
    • I'm using Nuget, version is v51.0.0
  • What architecture x86 or x64?
    Our embedded system needs to be x86 and x86 generated, but our computer is 64 bits.
  • On what operating system?
    • Win10
  • Are you using WinForms, WPF or OffScreen?
    I`m using ‘WPF’.
  • What steps will reproduce the problem?
    • Access to information, the blog post said that the issue had been resolved, but there have been. The solution is to change the source. The Code as follows:
      `//CefSharp.Wpf.ChromiumWebBrowser file
      protected override void OnPreviewTextInput(TextCompositionEventArgs e)
      {

          foreach (char t in e.Text)
          {
               browser.GetHost().SendKeyEvent((int)WM.CHAR, (int)t, 0); // or WM.IME_CHAR?
          }
      base.OnPreviewTextInput(e);
      

      }`
      can you want to ask there are other ways to solve it, or when it can be repaired, because I was using the CefSharp reference Nuget,My English is Poor. Thanks,

  • What is the expected output? What do you see instead?
    Expected output Chinese
  • Please provide any additional information below.
    • A stack trace if available, any Exception information.
      But there is no
    • Does the cef log provide any relevant information? (By default there should be a debug.log file in your bin directory)
      This can not be through log query
    • Any other background information that's relevant? Are you doing something out of the ordinary? 3rd party controls?
      I want to show the Html page, and input information
  • Does this problem also occur in the Cef TestApp from http://opensource.spotify.com/cefbuilds/index.html (http://cefbuilds.com for older version)?
@amaitland
Copy link
Member

Duplicate of #1262

@amaitland
Copy link
Member

can you want to ask there are other ways to solve it, or when it can be repaired, because I was using the CefSharp reference Nuget,

You can apply the change without modifying the source, not sure why someone would recommend that. You can either subclass ChromiumWebBrowser or simply subscribe the the event (just like any other WPF event).

browser.PreviewTextInput += (o, e) =>
{
    foreach (var character in e.Text)
    {
        browser.GetHost().SendKeyEvent((int)WM.CHAR, (int)character, 0);
    }

    e.Handled = true;
};

See #1262 (comment) for instructions on testing this issue and reporting the bug to the CEF project where it likely needs to be fixed.

@mayuxian
Copy link
Author

Ok. Thanks. I See.

@zhailei2014
Copy link

My .net is v4.5.0 so i can just use cefsharp.wpf v47.0.4
I have the same problem in win10.
but the function SendKeyEvent() neet just one param .... KeyEvent.
I don`t know how to set the keyevent param
I have tried like this:

    private void browser_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
    {
        foreach (char t in e.Text)
        {
            if (IsChinese(t))
            {
                KeyEvent ev = new KeyEvent();
                ev.NativeKeyCode = t;
                ev.WindowsKeyCode = (int)WM.CHAR;
                ev.Type = KeyEventType.KeyDown;
                browser.GetBrowser().GetHost().SendKeyEvent(ev);
            }
        }
        base.OnPreviewTextInput(e);
    }

but it doesn`t work ..
can you help me?

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

No branches or pull requests

3 participants