MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Unity | HoloLens 2 - MouseEventsWebView.MouseEvent does nothing?

Open
#3,681 8 comments 0 reactions 1 assignee View on GitHub

@michaelfarnsworth is already working on this.

Since Aug 3, 2023.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Question:
I have WebView2 set up in my Unity project. Now I would like to transfer my clicks from a canvas to the WebView. However, nothing happens after passing a WebViewMouseEventData. Did I forget something or do I have to update something again myself?

I have read the following article and at the end it roughly shows how to do it.

And even if I send wrong coordinates, I would have to send randomly usable coordinates at some point so that something on the web page gets clicked. But that doesn't happen.

Does there need to be more done than just handing over the MouseEvent?

My Setup:

        public void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            var result = eventData.Pointer.Result;
            if (result.CurrentPointerTarget.layer != 30)
            {
                Debug.Log("OnPointerClicked>layer != 30");
                return;
            }

            var clickPosition = result.Details.PointLocalSpace;
            var x = (int)Math.Ceiling(clickPosition.x);
            var y = (int)Math.Ceiling(clickPosition.y);
            Debug.Log("OnPointerClicked > X: " + x + " Y: " + y);

            var mouseEventsWebView = _webView as IWithMouseEvents;
            WebViewMouseEventData mouseEvent = new WebViewMouseEventData
            {
                X = x,
                Y = y,
                Device = WebViewMouseEventData.DeviceType.Pointer,
                Type = WebViewMouseEventData.EventType.MouseDown,
                Button = WebViewMouseEventData.MouseButton.ButtonLeft,
                TertiaryAxisDeviceType = WebViewMouseEventData.TertiaryAxisDevice.PointingDevice
            };

            mouseEventsWebView.MouseEvent(mouseEvent);
        }

WebView

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.