其他分享
首页 > 其他分享> > 解决cefSharp的wpf版本里无法输入中文的问题

解决cefSharp的wpf版本里无法输入中文的问题

作者:互联网

chromeBrowser = new ChromiumWebBrowser(Models.StaticList.ApiUrl + "/Home/Menu");
                    chromeBrowser.MenuHandler = new MenuHandler();
                    chromeBrowser.HorizontalAlignment = HorizontalAlignment.Stretch;
                    chromeBrowser.VerticalAlignment = VerticalAlignment.Stretch;
                    chromeBrowser.PreviewTextInput += (obj, args) =>
                     {
                         foreach (var character in args.Text)
                         {
                             // 把每个字符向浏览器组件发送一遍
                             chromeBrowser.GetBrowser().GetHost().SendKeyEvent((int)WM.CHAR, (int)character, 0);
                         }
                         // 不让cef自己处理
                         e.Handled = true;
                     };
                    chromeBrowser.LostFocus += ChromeBrowser_LostFocus;
                    chromeBrowser.GotFocus += ChromeBrowser_GotFocus;
                    chromeBrowser.WpfKeyboardHandler = new CefSharp.Wpf.Experimental.WpfImeKeyboardHandler(chromeBrowser);

最后一行,加粗的部分加上后就解决了

 

来源:https://github.com/cefsharp/CefSharp/issues/1262

 

 

标签:中文,LostFocus,Stretch,ChromeBrowser,cefSharp,chromeBrowser,new,wpf,CefSharp
来源: https://www.cnblogs.com/wjx-blog/p/16345449.html