tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
912 stars 74 forks source link

Interacting with the DOM #51

Closed ameisen closed 3 years ago

ameisen commented 3 years ago

Hi there! I'm wanting to port a codebase from Bridge.NET to this (or something similar). Since it's Bridge, the C# in there basically is constantly interacting directly with the DOM - it is just C# that ends up being transpiled to Java.

Going over this project's APIs.... there doesn't appear to be any awareness of the DOM at all. Am I correct that the only way to really manipulate it would be to write a wrapper on the Javascript side that reads web messages telling it to manipulate a DOM object, and then sending a web message back indicating whether or not the task was completed? Is there already an existing library to do this?

I see difficulties in that this makes effectively every DOM operation an asynchronous task, whereas some do require responses (such as the creation of an element, you need a handle back). You can, of course, make everything that interacts with the DOM wait for a response using some kind of ID, but it does complicate it.

professorotto commented 3 years ago

You are correct, there isn't a way to gain access to or manipulate DOM objects from C#. Your idea of a JS wrapper sounds feasible, but we are not aware of an existing library or package to do it. Ultimately, this is not something Photino was designed to do though, so we are not planning to incorporate that functionality ourselves at this point.

Anyhow: Any html + JS created by Bridge.NET can be run in a browser control. For example, you could load the Bridge.NET created html into Photino. The only thing you cannot do is manipulate the DOM from Photino's C# side.

theolivenbaum commented 3 years ago

@ameisen if you're interested: I've a fork of Bridge that is maintained here. You can set the output folder in the h5.json file to the wwwroot folder from Photino, and it's a quite nice pure C# experience :)

ameisen commented 3 years ago

@theolivenbaum Indeed, I've been engaged in an e-mail conversation with you about it :)

theolivenbaum commented 3 years ago

Small world! Did you receive my last email? It bounced once on your mailbox, seemed like DNS issues...

ameisen commented 3 years ago

@theolivenbaum I did not. Try resending, since I am getting the e-mail notifications from this thread.