picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.68k stars 334 forks source link

Add WebView.MessageReceived #2675

Open camnewnham opened 3 months ago

camnewnham commented 3 months ago

Hello! Initial draft for discussion.

The goal of this PR is to create a uniform approach to sending events from JS to Eto. Combined with the existing ExecuteScript it should allow for bi-directional communication (without polling).

Since each browser implementation significantly differs this approach is intended to keeps it simple by adding a single object /method to the global JavaScript context.

Example usage:

function isRunningInEto() {
  return window.eto !== undefined;
}

function onButtonClick() {
   window.eto.postMessage("The button was clicked!");
}

Supported Implementations:

Not implemented:

cwensley commented 3 months ago

Hey @camnewnham, this is looking great! This will help a lot of custom script scenarios.

Do you need help with the GTK implementation or is that something you'll be able to do?

camnewnham commented 3 months ago

Do you need help with the GTK implementation or is that something you'll be able to do?

That would be appreciated - I don't currently have a Linux machine (or is this testable on other platforms?)

Is a legacy WebKit.WebView implementation required?