Skip to content

Edge: Implement mouse-related event listener support #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sratz
Copy link
Member

@sratz sratz commented May 5, 2025

  • MouseListener

    • up
    • down
    • doubleClick
  • MouseMoveListener

    • move
  • MouseTrackListener

    • exit
    • enter
  • MouseWheelListener

    • scroll
  • DragDetectListener

    • dragDetected

The implementation is JavaScript-based by attaching listeners to the DOM for all relevant events and forwarding them to the WebView via window.chrome.webview.postMessage().

The event handling is analogous to IE's
IE#handleDOMEvent(org.eclipse.swt.ole.win32.OleEvent).

Note: Since the implementation is JavaScript-based, this requires JavaScript to be enabled on the Browser instance.

When JavaScript is disabled, we keep using the timer-based fallback implementation introduced in #1551.
As JavaScript is only truly enabled after navigation has finished, we also keep using this workaround when the Browser is first instantiated and before the first page has loaded.

This change also fixes the jsEnabled flag lifecycle by updating it in handleNavigationCompleted(), same as in IE.

This resolves #2164 as long as JavaScript is enabled.

@sratz sratz added the edge Edge Browser label May 5, 2025
Copy link
Contributor

github-actions bot commented May 5, 2025

Test Results

   546 files  ±0     546 suites  ±0   35m 54s ⏱️ + 3m 4s
 4 425 tests ±0   4 408 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 746 runs  ±0  16 618 ✅  - 1  128 💤 +1  0 ❌ ±0 

Results for commit c8ac9dd. ± Comparison against base commit d4c3036.

♻️ This comment has been updated with latest results.

@HeikoKlare
Copy link
Contributor

HeikoKlare commented May 5, 2025

@sratz
Copy link
Member Author

sratz commented May 5, 2025

May this fix ...?

Not sure.

I just remember that we've been down this road before.

The problem is that if we disable JavaScript via ICoreWebView2Settings.put_IsScriptEnabled(boolean), this will also prevent those listeners from running :(

@akurtakov
Copy link
Member

Is this still being considered?

@HeikoKlare
Copy link
Contributor

Is this still being considered?

Yes, we still have #2164 and just had an offline talk about how we want to proceed with this a few weeks ago. I expect that we proceed with this or have something else supercede it in the next weeks.

@sratz sratz force-pushed the edge_mouseevents branch from 0d75c70 to b17cd3f Compare August 12, 2025 11:13
@sratz
Copy link
Member Author

sratz commented Aug 12, 2025

Is this still being considered?

Yes, we still have #2164 and just had an offline talk about how we want to proceed with this a few weeks ago. I expect that we proceed with this or have something else supercede it in the next weeks.

As discussed offline, I changed the implementation to keep the fallback in place

  • before first page load (where we don't have any javascript yet)
  • when javascript is disabled

- MouseListener
  up
  down
  doubleClick

- MouseMoveListener
  move

- MouseTrackListener
  exit
  enter

- MouseWheelListener
  scroll

- DragDetectListener
  dragDetected

The implementation is JavaScript-based by attaching listeners to the
DOM for all relevant events and forwarding them to the WebView via
window.chrome.webview.postMessage().

The event handling is analogous to IE's
IE#handleDOMEvent(org.eclipse.swt.ole.win32.OleEvent).

Note: Since the implementation is JavaScript-based, this requires
JavaScript to be enabled on the Browser instance.

When JavaScript is disabled, we keep using the timer-based fallback
implementation introduced in eclipse-platform#1551.
As JavaScript is only truly enabled *after* navigation has finished, we
also keep using this workaround when the Browser is first instantiated
and before the first page has loaded.

This change also fixes the jsEnabled flag lifecycle by updating it in
handleNavigationCompleted(), same as in IE.

This resolves eclipse-platform#2164 as long as JavaScript is enabled.
@sratz sratz force-pushed the edge_mouseevents branch from b17cd3f to c8ac9dd Compare August 12, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
edge Edge Browser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edge: addMouseWheelListener and addMouseListener have no effect
3 participants