API for getting an event when to open a virtual keyboard

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

API for getting an event when to open a virtual keyboard

Postby riku » Fri Feb 22, 2019 6:32 am

I'm using CEF in a multi-user multi-touch environment where you can have multiple browsers open, and several people interacting with them at the same time. We use OSR mode and have our custom on-screen keyboard - and obviously we can have several keyboards open at the same time as well.

I would like to know when to open and close these virtual keyboard, and also what kind of keyboard to open (standard, numeric, email, decimal etc).

Previously (with CEF 2883) I did this by patching CEF and adding a new callback for this, but I used some Chromium API that is now gone, so I need to redo this for 3683. I have now test code that uses content::TextInputManager::Observer::OnUpdateTextInputStateCalled to find out when to open the keyboard, and what kind of keyboard is requested. I also added virtual void CefRenderHandler::OnVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser, CefTextInputMode mode) where the text input mode is practically just ui::TextInputMode.

Does this approach make sense? Is there already some way of doing this that I just didn't find? Is CefRenderHandler the correct place to add this? I'm planning on adding this just for off-screen rendering mode, most likely it won't be so useful for windowed rendering when you most likely can just use some system virtual keyboard.

Should I just open a pull request for this? I think I can trivially add a unit test for this.
riku
Techie
 
Posts: 15
Joined: Mon Feb 18, 2019 4:42 am

Re: API for getting an event when to open a virtual keyboard

Postby magreenblatt » Fri Feb 22, 2019 10:52 am

I wonder if it's possible to detect this using JavaScript. I would recommend looking into that before making CEF/Chromium changes.
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Re: API for getting an event when to open a virtual keyboard

Postby riku » Fri Feb 22, 2019 11:20 am

You mean by injecting some JS code to all websites? That sounds somewhat dangerous operation.

This was a trivial patch to CEF: https://bitbucket.org/riku_palomaki/cef ... 8a975b93db - this basically mirrors the functionality already in RenderWidgetHostViewAura.
riku
Techie
 
Posts: 15
Joined: Mon Feb 18, 2019 4:42 am

Re: API for getting an event when to open a virtual keyboard

Postby magreenblatt » Fri Feb 22, 2019 11:32 am

What happens if you don't implement OnUpdateTextInputStateCalled? Is no virtual keyboard displayed?
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Re: API for getting an event when to open a virtual keyboard

Postby riku » Fri Feb 22, 2019 11:42 am

Not sure what you mean. OnUpdateTextInputStateCalled comes from TextInputManager::Observer. I added CefRenderWidgetHostViewOSR as a new observer to TextInputManager. If you don't implement it, there are no side effects.
riku
Techie
 
Posts: 15
Joined: Mon Feb 18, 2019 4:42 am

Re: API for getting an event when to open a virtual keyboard

Postby magreenblatt » Fri Feb 22, 2019 11:45 am

OK, I see. What is your use case for this callback?
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Re: API for getting an event when to open a virtual keyboard

Postby riku » Fri Feb 22, 2019 11:58 am

We have our custom virtual keyboard implementation in our OpenGL based application running on a huge touch-enabled video wall. Users can interact with lots of UI elements, including web browsers. All the browsers have their own virtual keyboards, but to space screen estate, they are hidden by default. When they tap on some input field on the browser, or do some other action that Chromium thinks needs text input, we spawn a new virtual keyboard nearby the user.

For instance, user goes to google.com, and OnVirtualKeyboardRequested will be called with TEXT_INPUT_MODE_DEFAULT and we will open a new keyboard. Then user writes the search query and taps on enter, and then OnVirtualKeyboardRequested will be called with TEXT_INPUT_MODE_NONE and we will hide the keyboard.
riku
Techie
 
Posts: 15
Joined: Mon Feb 18, 2019 4:42 am

Re: API for getting an event when to open a virtual keyboard

Postby magreenblatt » Fri Feb 22, 2019 12:32 pm

What happens in a touch-enabled OSR application if you don't provide your own custom virtual keyboard implementation? Will a virtual keyboard be displayed by Chromium or the system?
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Re: API for getting an event when to open a virtual keyboard

Postby riku » Fri Feb 22, 2019 2:00 pm

I don't think CEF opens any kind of virtual keyboard by default in OSR mode. RenderWidgetHostViewAura triggers the keyboard on Windows using InputMethodKeyboardController, but CefRenderWidgetHostViewOSR doesn't do anything like that. And I think that's all correct. In our case we never want to see any native UI.
riku
Techie
 
Posts: 15
Joined: Mon Feb 18, 2019 4:42 am

Re: API for getting an event when to open a virtual keyboard

Postby magreenblatt » Fri Feb 22, 2019 2:08 pm

If I'm understanding correctly your new callback is needed for the client to display a virtual keyboard on touch event. That seems quite reasonable. Please create an issue and submit your change as a PR.
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Next

Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 1 guest