ElectronControl

package module
v0.0.0-...-7cc36fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2016 License: MIT Imports: 3 Imported by: 0

README

go-electroncontrol

Golang bindings for electroncontrol

Usage

err := Initialize()
defer Shutdown()

SetCommandArguments("c:/myapp")

electron, err := New()

window, err := electron.CreateWindow(shell.WindowOptions{
    Width: 700,
    Height: 700,
    Frame: false,
    Show: true})
defer window.Close()

// load a webpage
err = window.LoadURL("http://google.com")

// send an event to the app
data, err := json.Marshal(myData)
window.Message("my_event", data)

// create a callback and listen to an event from the BrowserWindow
cb := func (data []byte) {json.UnMarshal(data, &myData)}
window.Listen("my_event_from_webview", cb)

API

To use this you need an install of electron, as well as the electroncontrol app.

Set up the Path and command line so that go-electroncontrol can control your shell.

I would suggest you use something like go-bindata to package electron WITH your GO app, and then decompress on first startup.

ElectronControl

SetPath: Sets the path of electron(.exe)


SetExecutableName: Set the name of electron. (in case you want to rename it)


SetCommandArguments: VA ARGS that are the command switches to pass into electron.


New: Loads an instance of electron. Returns a *shell.Electron that can be used.


Initialize: Set up ElectronControl and get it ready.


Shutdown: Shut down.


Shell

Electron::Command: Sends a command to that instance of Electron. Not intended to be called directly.


Electron::Listen: Listens to a command from electron. Not intended to be called directly.


Electron::CreateWindow: Create a new window on the instance of electron. Takes a shell.WindowOptions which (fits a golang case convention) but has the same names as used in electron's new BrowserWindow(options).


Window::Close: Closes an active window.


Window::LoadURL: Load a URL in the window. Blocks until the URL load is complete.


Window::Listen: Allows a callback to be sent to a BrowserWindow. This, along with Window::Message allow direct communication with the webview.


Window::OpenDevTools: Opens the webkit developer tools pannel.


Window::CloseDevTools: Closes the webkit developer tools panel.


Window::OnClosed: Allows a callback to be registered for when a user closes a window.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize() error

Initialize - Sets up ElectronControl

func New

func New() (*shell.Electron, error)

New - launches electronExeName and opens a connection.

func SetCommandArguments

func SetCommandArguments(args ...string)

SetCommandArguments - sets the command arguments that get passed into electron on launch.

func SetExecutableName

func SetExecutableName(name string)

SetExecutableName - sets the name of the executeable that is going to get launched.

func SetPath

func SetPath(path string)

SetPath - sets the path that the system should look for electron in.

func SetWorkingDir

func SetWorkingDir(dir string)

SetWorkingDir - set the working dir of electron.exe

func Shutdown

func Shutdown()

Shutdown - closes down ElectronControl.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL