Welcome Guest Search | Active Topics | Sign In | Register

Catch/handle touch wm_message in winform Options
KhiDan
Posted: Friday, October 14, 2022 2:21:34 AM
Rank: Newbie
Groups: Member

Joined: 2/25/2020
Posts: 8
Hi all.
We use EO.WebBrowser inside the kiosk app on Windows 10.
Kiosks use very high quality multitouch screens.
How can I handle touch input event/message in winform/c#?
The point is that we need to track the activity of using the kiosk application.
InputMsgFilter catch keyboard and mouse messages, but not touch.
eo_support
Posted: Friday, October 14, 2022 11:52:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

There is no way for you to directly handle touch event on the C# side. You would need to handle the touch event with JavaScript and then call into C# from your JavaScript code. The basic steps can be like this:

1. Use WebView.JSInitCode to inject additional JavaScript code into the page that handles the touch event. For example, the following code handles document.body.touchstart event in JavaScript;

Code: JavaScript
webView.JSInitCode = @"
window.addEventListener('load', function(e)
{{
  document.body.addEventListener('touchstart', function(e)
  {{
    eoapi.extInvoke('touchStart');
  }});
}});
";


2. Handle the touch event however you need in your JavaScript code. Then when necessary calls into C# side through eoapi.extInvoke. For demonstration purpose the above code calls into C# side immediately from touchstart event handler. In practice this is not recommended. For performance reason, it is recommended that you do as much work as possible in JavaScript code and then only "report" the result back to C# side. For example, if you need to handle touch event to implement drag and drop an item from one place to another place in your page, instead of calling into C# side on every touch event (touchstart, touchmove, touchend, touchcancel), you can handle all these events in JavaScript code and only calls back to C# side when an item has been successfully dropped;

3. You would then handle WebView.JSExtInvoke event on C# side that handles the JavaScript side eoapi.extInvoke call;

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.