summaryrefslogtreecommitdiff
path: root/delegate_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-01 21:34:37 -0500
committerPietro Gagliardi <[email protected]>2014-03-01 21:34:37 -0500
commitbbb37bb2a6446e555dd92572e8e27157d1a7f7f4 (patch)
tree31607f013fab33b3a9f794d47083486b49a74963 /delegate_darwin.go
parent859c240a2119d799ecae59be67e9ad96e1aa7b92 (diff)
Added Mac OS X Buttons. Code hangs due to a preferredSize() issue...
Diffstat (limited to 'delegate_darwin.go')
-rw-r--r--delegate_darwin.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/delegate_darwin.go b/delegate_darwin.go
index 8d27281..5c33e39 100644
--- a/delegate_darwin.go
+++ b/delegate_darwin.go
@@ -11,7 +11,7 @@ This creates a class goAppDelegate that will be used as the delegate for /everyt
- runs uitask requests (uitask:)
- handles window close events (windowShouldClose:)
- handles window resize events (windowDidResize: (TODO also windowDidEndLiveResize:?))
- - handles button click events (buttonClick:)
+ - handles button click events (buttonClicked:)
*/
// #cgo LDFLAGS: -lobjc -framework Foundation -framework AppKit
@@ -20,6 +20,7 @@ This creates a class goAppDelegate that will be used as the delegate for /everyt
// extern void appDelegate_uitask(id, SEL, id); /* from uitask_darwin.go */
// extern BOOL appDelegate_windowShouldClose(id, SEL, id);
// extern void appDelegate_windowDidResize(id, SEL, id);
+// extern void appDelegate_buttonClicked(id, SEL, id);
import "C"
var (
@@ -34,6 +35,7 @@ var (
_uitask = sel_getUid("uitask:")
_windowShouldClose = sel_getUid("windowShouldClose:")
_windowDidResize = sel_getUid("windowDidResize:")
+ _buttonClicked = sel_getUid("buttonClicked:")
)
func mkAppDelegate() error {
@@ -56,6 +58,11 @@ func mkAppDelegate() error {
if err != nil {
return fmt.Errorf("error adding NSApplication delegate windowDidResize: method (to handle window resize events): %v", err)
}
+ err = addDelegateMethod(appdelegateclass, _buttonClicked,
+ C.appDelegate_buttonClicked, delegate_void)
+ if err != nil {
+ return fmt.Errorf("error adding NSApplication delegate buttonClicked: method (to handle button clicks): %v", err)
+ }
// TODO using objc_new() causes a segfault; find out why
// TODO make alloc followed by init (I thought NSObject provided its own init?)
appDelegate = objc_alloc(objc_getClass(_goAppDelegate))
@@ -86,6 +93,12 @@ func appDelegate_windowDidResize(self C.id, sel C.SEL, notification C.id) {
}
}
+//export appDelegate_buttonClicked
+func appDelegate_buttonClicked(self C.id, sel C.SEL, button C.id) {
+ sysData := getSysData(button)
+ sysData.signal()
+}
+
// this actually constructs the delegate class
var (