on macOS, in JCEF, textArea cannot input chinese

Answered

我开发了一个idea的插件, 依赖插件平台为:com.jetbrains:idealC:2023.13, 插件使用JCEF打开一个本地html页面(by vue 2.x)。页面上有一个textArea输入域,在macOS中,idea安装该插件后,插件页面上的textArea不能输入中文。使用macOS上的浏览器打开该页面能输入中文,并且,在windows中,idea安装插件后,插件页面上的textArea也能输入中文。

切换中文输入法后,输入时能调起中文输入法,但是点空格选取中文时,输入框内未正确选取中文,而是直接键入了一个空格符,如下图所示,猜测是JCEF环境的文本输入策略(textarea)中的文本输入被设计为逐个字符地输入,而不是以词为单位。在文本框中输入中文并按下空格键时,并不会自动选取整个中文词汇。

 

0
4 comments

Please do not use languages other than English. We won't answer to non-English questions.

I suggest translating this post to English and letting me know, so I can see a notification.

You may also consider asking for help on the community Slack, on the Chinese channel.

https://plugins.jetbrains.com/docs/intellij/getting-help.html?section=Chinese

0

OK. I have developed a plugin for IntelliJ IDEA, relying on the plugin platform: com.jetbrains:idealC:2023.13, which opens a local HTML page using JCEF (by Vue 2.x). On this page, there is a textarea input field. In macOS, after installing this plugin in IntelliJ IDEA, the textarea on the plugin page cannot input Chinese characters. However, if you use the browser on macOS to open this page, you can input Chinese characters. Moreover, on Windows, after installing the plugin in IntelliJ IDEA, the textarea on the plugin page can also input Chinese characters.

After switching to Chinese input method, Chinese input method can be triggered when typing, but when selecting Chinese characters by clicking spacebar, the input field does not correctly select Chinese characters, but directly inputs a space character instead. As shown in the figure, it is suspected that the text input strategy (textarea) in the JCEF environment is designed to input characters one by one instead of words as a unit. When typing Chinese characters in the input field and pressing the space key, the entire Chinese word is not automatically selected.

0

Hi  Exception Bug ,

TL;DR: pass false to JBCefBrowserBuilder#setOffScreenRendering() and the browser will behave as before.

 

Starting 2023.2 we switched JCEF to off screen rendering(OSR). So now by default the native input method events are no longer processed by chromium. They are processed by JBR and forwarded to the browser. There are some issues with CEF input methods API that might lead to the problem described above.

Creating the browser with OSR mode disabled(by running idea with `-Dide.browser.jcef.osr.enabled=false` or to pass false to JBCefBrowserBuilder#setOffScreenRendering()) will make JCEF behave as it was before.  

 You may experience a couple old problems with OSR disabled:
- issues with rendering the components overlapping JCEF component(that's the main reason why we switched to OSR). 
- focus issues. The browser may not always return focus on request from the client code.

Hope it could solve the problem.

 

0

Thank you very much! The problem has been solved using the method provided above. I will check the current operating environment in the code, and if it is a Mac operating system, I will add `JBCefBrowserBuilder#setOffScreenRendering(false)` at startup to solve this issue and reduce the impact on rendering effects in the Windows environment.

0

Please sign in to leave a comment.