Programming a virtual keyboard for JCEF

Having problems with building or using the JCEF Java binding? Ask your questions here.

Re: Programming a virtual keyboard for JCEF

Postby FriwiDev » Sun Apr 24, 2022 5:06 am

As long as you use windowed rendering, it can be casted to a JPanel.
Maintainer of jcefmaven on GitHub.
FriwiDev
Techie
 
Posts: 41
Joined: Sun Jul 09, 2017 4:18 am

Re: Programming a virtual keyboard for JCEF

Postby alex9849 » Sun Apr 24, 2022 5:34 am

Oh great! I could really cast the component to JPanel and I could add the listener. The next problem is that that listener doesn't get executed. :cry:
alex9849
Newbie
 
Posts: 9
Joined: Thu Apr 21, 2022 9:45 am

Re: Programming a virtual keyboard for JCEF

Postby FriwiDev » Sun Apr 24, 2022 6:28 am

Which method did you overwrite? The yieldFocus or the verify method? If the InputVerifier method does not work, I'm out of ideas for now.
Maintainer of jcefmaven on GitHub.
FriwiDev
Techie
 
Posts: 41
Joined: Sun Jul 09, 2017 4:18 am

Re: Programming a virtual keyboard for JCEF

Postby alex9849 » Sun Apr 24, 2022 6:34 am

All methods. After the verify-method didn't work I tried to overwrite all other methods and check via breakpoint if any of them get executed.
alex9849
Newbie
 
Posts: 9
Joined: Thu Apr 21, 2022 9:45 am

Re: Programming a virtual keyboard for JCEF

Postby alex9849 » Sun Apr 24, 2022 6:47 am

I found something out. I checked the focusmanager of swing and created a listener that always prints out the currently selected component. It seems like the chromium tab never looses focus. There must be another reason why the input fields within the browser gets unfocused.
alex9849
Newbie
 
Posts: 9
Joined: Thu Apr 21, 2022 9:45 am

Re: Programming a virtual keyboard for JCEF

Postby FriwiDev » Mon Apr 25, 2022 3:25 am

Most likely the browser still receives the click events outside of its own scope in the same window.
Maintainer of jcefmaven on GitHub.
FriwiDev
Techie
 
Posts: 41
Joined: Sun Jul 09, 2017 4:18 am

Re: Programming a virtual keyboard for JCEF

Postby Phylanx » Tue Apr 26, 2022 1:46 am

As far as I know this could be a problem on the jcef java/native bridge.
The Components that you get by getComponent (I only know the windowed rendering mode with Operating System Windows 32 bit) is a Java Swing JPanel that contains a Java AWT Canvas.
The background on that:
AWT has real windows operating system component handles on every component. e.g.:a java.awt.Button is a real Microsoft Windows Operating System Button.
Swing is different.
A Swing component is just drawn by java on a plain window component (as far as I know that is the only real OS handle it has).
So if you have a JButton on in a window, the button is just drawn (no real OS handle in there). For the OS a click on the JButton is a click on a bare and plain window, only Java knows that a JButton is located on this location and translates the Events (OnClick, OnMouseOver, OnMouseLeft, Drag,...).
Now if you take a AWT Button and put it for example in a Swing JPanel this needs some special usecases...

With this knowledge in background let's take a look on the JCEF Components.
JCEFs getComponent gives you a JPanel. That is because Swing is very commonly used in Java and also very recommended.
In this Swings JPanel there lies a Canvas.
The reason in this is that the Chromium native libraries deep down below don't know of Javas Swing technology. They need a real OperatingSystem Component handle to draw on it.
And this is the Canvas used for AWT.

As you can imagine it is a hack of work to translate all Events that happen in the JCEF/CEF binaries so that Javas Swing JPanel and Java itself gets all needed Events.

JCEF had its problems (including painfull JVM Crashes) with it and has small issues still.

As far as I can say to the topic "Focus handling in JCEF" I would say this:
The less you meddle with it the better it works.
------------
btw... is there a reason why you can't use the normal Operating systems keyboard?
doesn't the OperatingSystem recognize that you focussed a component that should enable the virtual keyboard?
Phylanx
Expert
 
Posts: 201
Joined: Thu Aug 11, 2016 8:17 am

Previous

Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 18 guests