How to enter/exit touch mode or send touch event?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to enter/exit touch mode or send touch event?

Postby ranma » Wed Feb 20, 2019 9:13 pm

I embedded a CEF browser in the C# winform project. When I browse to a page, I need to use the touch event to click a button. The click event using javascript will be invalid. I can only open devtool by “touch:force-enabled" option. I also added "touch-devices=enabled" when the browser is initializing, but it also didn't work. So how do I get the browser to enter/exit touch mode? Or is there any other way to send a touch message to the browser?
My English may be a little bad, I hope everyone can understand, thank you for helping me!
These codes are invalid:
settings.CefCommandLineArgs.Add("touch-devices", "enabled");
settings.CefCommandLineArgs.Add("touch-events", "enabled");
Await webBrowser1.GetMainFrame().EvaluateScriptAsync("document.getElementsByClassName('in-need-pay-text')[0].click()");
ranma
Newbie
 
Posts: 3
Joined: Wed Feb 20, 2019 8:53 pm

Re: How to enter/exit touch mode or send touch event?

Postby amaitland » Wed Feb 20, 2019 10:10 pm

What is the exact reason you need to use a touch event? You control the browser, you can control how the buttons behave.

Setting the button to focus then sending an enter key press is often very successful.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am

Re: How to enter/exit touch mode or send touch event?

Postby magreenblatt » Wed Feb 20, 2019 10:53 pm

@ranma You need to use the “post reply” button to post a response on this thread.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to enter/exit touch mode or send touch event?

Postby ranma » Wed Feb 20, 2019 11:00 pm

amaitland wrote:What is the exact reason you need to use a touch event? You control the browser, you can control how the buttons behave.

Setting the button to focus then sending an enter key press is often very successful.

Thank you for your reply, but I have tried this and I have tried it, it is useless, whether it is a click event, a keyboard event, or I directly operate the mouse and keyboard to operate, the page only supports the touch event.
ranma
Newbie
 
Posts: 3
Joined: Wed Feb 20, 2019 8:53 pm

Re: How to enter/exit touch mode or send touch event?

Postby magreenblatt » Wed Feb 20, 2019 11:04 pm

That sounds like a broken website if it doesn’t allow clicking with a mouse event.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to enter/exit touch mode or send touch event?

Postby ranma » Wed Feb 20, 2019 11:25 pm

magreenblatt wrote:That sounds like a broken website if it doesn’t allow clicking with a mouse event.

The website is good, other pages can use the click event, whether it is a manual click or a javascript click, only that special page is invalid, you must switch the browser to device emulator or force to touch mode, then the mouse will become a black Translucent circle, then click is effective
ranma
Newbie
 
Posts: 3
Joined: Wed Feb 20, 2019 8:53 pm

Re: How to enter/exit touch mode or send touch event?

Postby amaitland » Thu Feb 21, 2019 12:27 am

Open `DevTools` and determine exactly what this so called Button actually is.

You can likely modify the css/html dom to change this element to be clickable, or find out what function it calls and execute that directly.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 49 guests