package main /* #cgo CFLAGS: -x objective-c #cgo LDFLAGS: -framework Foundation #include "handler.h" */ import "C" import ( "log" "github.com/andlabs/ui" ) // Sources used to figure this out: // Info.plist: https://gist.github.com/chrissnell/db95a3c5ad6ceca4c673e96cca0f7548 // custom url handler example: http://fredandrandall.com/blog/2011/07/30/how-to-launch-your-macios-app-with-a-custom-url/ // obj-c example: https://gist.github.com/leepro/016d7d6b61021dfc67daf61771c92b3c // note: import .h, not .m var labelText chan string func main() { log.SetFlags(log.Lshortfile) labelText = make(chan string, 1) // the event handler blocks!, so buffer the channel at least once to get the first message C.StartURLHandler() err := ui.Main(func() { greeting := ui.NewLabel("greeting\nline 2") window := ui.NewWindow("Hello", 200, 100, true) window.SetChild(greeting) window.OnClosing(func(*ui.Window) bool { ui.Quit() return true }) window.Show() go func() { for text := range labelText { ui.QueueMain(func() { greeting.SetText(text) }) } }() }) if err != nil { log.Fatal(err) } } //export HandleURL func HandleURL(u *C.char) { labelText <- C.GoString(u) }