Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Guidance on extending Go <-> Electron Interop #62

Open
Naatan opened this issue Sep 9, 2022 · 2 comments
Open

Guidance on extending Go <-> Electron Interop #62

Naatan opened this issue Sep 9, 2022 · 2 comments

Comments

@Naatan
Copy link

Naatan commented Sep 9, 2022

Hi there,

I'm looking into adding some functionality to astilectron and am unfortunately running into barriers due to my unfamiliarity with the codebase. Hoping to get some guidance via this ticket, and will be happy to open up PRs for the enhancements I'm looking to make.

I'm looking to expose electron features like:

I've been experimenting with index.js to try and add the functionality I need but it's slow going. Namely I can't seem to figure out how to send and receive messages between Go and electron. The code that exists for this is so low level that it's hard to follow along with without educating myself on the entirety of the codebase.

Any chance someone could provide some pointers on how I would go above adding more interop between Go and electron? A simple "hello world" example for sending messages to/from electron would be tremendously helpful.

Thank you!

@asticode
Copy link
Owner

asticode commented Sep 9, 2022

First off thanks for taking an interest in this project.

Regarding menus, it should already be possible to create them using this GO function. Or is your use case missing in this lib?

As for dialogs it's a little bit more complex since one need to mix code both in the main and renderer process 🤔

Here's how to send a message to go :

client.write(targetId, eventName, payload)

Here's how to send a message to js :

synchronousEvent(ctx, object, writer, payload, eventName)

You can check out the Blur function to see how it works.

@Naatan
Copy link
Author

Naatan commented Sep 10, 2022

Thanks! I was able to put something together; #63

For the menu's - I'm not certain yet whether I will need to add something. From what I gather electron only facilitates the menubar and not context menu's, but I've seen some node.js packages that add this functionality. I assumed I would have to do something similar.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants