From d018953d7ef1b276cc3229e04ba6fc75018c888a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 2 Aug 2014 22:35:58 -0400 Subject: Split all the Control implementations into their own files and renamed the containerctrls implementation files to say tab instead as they only hold Tab. This is the first part of what should hopefully be the final restructuring. --- redo/button_darwin.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 redo/button_darwin.go (limited to 'redo/button_darwin.go') diff --git a/redo/button_darwin.go b/redo/button_darwin.go new file mode 100644 index 0000000..e5a7f5b --- /dev/null +++ b/redo/button_darwin.go @@ -0,0 +1,52 @@ +// 16 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +type button struct { + *controlbase + clicked *event +} + +func finishNewButton(id C.id, text string) *button { + ctext := C.CString(text) + defer C.free(unsafe.Pointer(ctext)) + b := &button{ + controlbase: newControl(id), + clicked: newEvent(), + } + C.buttonSetText(b.id, ctext) + C.buttonSetDelegate(b.id, unsafe.Pointer(b)) + return b +} + +func newButton(text string) *button { + return finishNewButton(C.newButton(), text) +} + +func (b *button) OnClicked(e func()) { + b.clicked.set(e) +} + +//export buttonClicked +func buttonClicked(xb unsafe.Pointer) { + b := (*button)(unsafe.Pointer(xb)) + b.clicked.fire() + println("button clicked") +} + +func (b *button) Text() string { + return C.GoString(C.buttonText(b.id)) +} + +func (b *button) SetText(text string) { + ctext := C.CString(text) + defer C.free(unsafe.Pointer(ctext)) + C.buttonSetText(b.id, ctext) +} -- cgit v1.2.3