Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 2.07 KB

File metadata and controls

85 lines (63 loc) · 2.07 KB

gocoa

GoDoc Go Report Card

Go bindings for the Cocoa framework to build macOS applications.

Goal: target macOS 10.15 and upper without deprecated methods support

How to use

package main

import (
	"fmt"

	"github.com/magicfun1241/gocoa/appkit"
)

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

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

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

	wnd.MakeKeyAndOrderFront()
	appkit.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.

Partial implementation

Not all methods are implemented

Components

  • TextView
  • TextField
  • SearchField
  • ImageView
  • Button
  • DatePicker
  • ComboBox
  • ProgressIndicator
  • Slider
  • WebView
  • View
  • LayoutConstraint

Methods

  • RunOnMainThread

Additional APIs

  • UserDefaults

Contributors

This is fork of gocoa with already merged pull request and small refactor

Notice from original repository:

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