Skip to content
/ gocoa Public

Go bindings for the Cocoa framework to build macOS applications

License

Notifications You must be signed in to change notification settings

mojbro/gocoa

Repository files navigation

gocoa

GoDoc Go Report Card

Go bindings for the Cocoa framework to build macOS applications.

How to use

The following is a basic Hello World application.

package main

import (
	"fmt"

	"github.com/mojbro/gocoa"
)

func main() {
	gocoa.InitApplication()
	gocoa.OnApplicationDidFinishLaunching(func() {
		fmt.Println("App running!")
	})
	wnd := gocoa.NewWindow("Hello World!", 150, 150, 300, 200)

	// Change me button
	currentTitle, nextTitle := "Change me!", "Change me again!"
	changeButton := gocoa.NewButton(75, 125, 150, 25)
	changeButton.SetTitle(currentTitle)
	changeButton.OnClick(func() {
		changeButton.SetTitle(nextTitle)
		currentTitle, nextTitle = nextTitle, currentTitle
	})
	wnd.AddButton(changeButton)

	// Quit button
	quitButton := gocoa.NewButton(75, 50, 150, 25)
	quitButton.SetTitle("Quit")
	quitButton.OnClick(func() { gocoa.TerminateApplication() })
	wnd.AddButton(quitButton)

	wnd.MakeKeyAndOrderFront()
	gocoa.RunApplication()
}

Status of this project

This package is very, very early and incomplete! It is mostly just an experiment and is not really useful yet.

Contributors

Big thanks to Philipp Haussleiter who has contributed a great deal to this project.

About

Go bindings for the Cocoa framework to build macOS applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published