简体   繁体   中英

Intercept mouse back and forward in UWP WebView

In my UWP app I can detect if the user presses the backward or the forward button (XButton1 and XButton2) on their mouse.

The problem is when the presses are done over a WebView, as they are then being caught there.

I have tried using the WebView's ScriptNotify function, but trough JavaScript I can only detect Mouse 1, 2, and 3:

document.onmousedown = function (e) { notify('mousepressed', e.which); };

So my question is if there is any way to intercept the mouse clicks before they reaches the WebView? If so, I also need to be able to pass on the clicks if they are not XButton1 and 2, as "regular" clicks are needed in the WebView.

Try handling the CoreWindows.PointerDown event:

Window.Current.CoreWindow.PointerPressed += PointerPressedHandler;

CoreWindow events are usually the best place to handle global input, it may handle the pointer before it reaches the WebView .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM