A few small fixes.

This commit is contained in:
gmp
2019-05-24 15:40:01 -04:00
parent 34fbcec965
commit 86ff14b533
5 changed files with 61 additions and 22 deletions
+26 -5
View File
@@ -10,6 +10,15 @@ import (
//Shortcut for literal NSStrings
var nst = ns.NSStringWithGoString
func pb1() {
fmt.Println("Pushed button 1")
}
func pb2() {
fmt.Println("Pushed button 2")
a.Terminate(a)
}
func didFinishLaunching(n ns.NSNotification) {
fmt.Println("Go: did finish launching")
fmt.Printf("Notification: %s\n",n.Name().UTF8String())
@@ -50,13 +59,25 @@ func didFinishLaunching(n ns.NSNotification) {
a.SetMainMenu(m1)
//add some buttons and do some layout
//add some custom buttons
//don't do this:
//b := ns.NSButtonAlloc().InitWithFrame(ns.NSMakeRect(100,100,100,50))
b1 := ns.GButtonAlloc()
b2 := ns.GButtonAlloc()
b1.Init()
b1.PressedCallback(pb1)
b1.SetAction(ns.Selector("pressed"))
b1.SetTarget(b1)
b1.SetTitle(nst("PUSH"))
b2.Init()
b2.PressedCallback(pb2)
b2.SetTarget(b2)
b2.SetAction(ns.Selector("pressed"))
b2.SetTitle(nst("QUIT"))
//add some layout constraints
b1 := ns.NSButtonWithTitle(nst("PUSH"),ns.Id{},ns.Selector(""))
b2 := ns.NSButtonWithTitle(nst("QUIT"),ns.Id{},ns.Selector("terminate:"))
b1.SetTranslatesAutoresizingMaskIntoConstraints(0)
b2.SetTranslatesAutoresizingMaskIntoConstraints(0)
+7 -3
View File
@@ -5,7 +5,6 @@ inputfiles:
classes:
- NSAutoreleasePool
- NSEnumerator
- NSString
- NSApplication
- NSWindow
@@ -13,14 +12,14 @@ classes:
- NSMenu
- NSMenuItem
- NSButton
- NSControl
- NSNotification
- NSStackView
- NSLayoutConstraint
- NSDictionary
- NSArray
- NSObject
functions: [NSMake.*]
functions: [ NSMakeRect ]
enums:
- NSApplication.*
@@ -38,6 +37,11 @@ delegates:
- applicationShouldTerminateAfterLastWindowClosed
- applicationDidBecomeActive
subclasses:
GButton:
NSButton:
- -(void)pressed
frameworks: [ Foundation, AppKit ]
pragma: [ clang diagnostic ignored "-Wformat-security" ]
+2 -1
View File
@@ -15,6 +15,7 @@ func main() {
n2 := ns.NSStringAlloc()
n2 = n2.InitWithGoString("hi world")
n3 := ns.NSStringWithGoString("ok bye")
fmt.Printf("%s\n",n3)
a := ns.NSMutableArrayWithObjects(n1,n2,n3)
fmt.Println("Length(a) = ",a.Count())
fmt.Println("is n2 in a?",a.ContainsObject(n2))
@@ -30,7 +31,7 @@ func main() {
fmt.Printf("i1 = %@\n",i1)
fmt.Printf("i1.Ptr() = %p\n",i1.Ptr())
a.ObjectEnumerator().ForIn(func(o ns.Id) bool {
fmt.Println(o.NSString().UTF8String())
fmt.Println(o.NSString())
return true
})
s1 := ns.NSSetWithObjects(n1,n2)
+1 -1
View File
@@ -4,7 +4,7 @@ classes:
- ClassOne
- ClassTwo
subclasses:
ClassThree:
classThree:
ClassTwo:
- geti1
- -(void)myMethod1:(int)a