From 08f6e6beeb618f9b55329e5a861c595db7334f65 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 24 Oct 2014 16:38:23 -0400 Subject: [PATCH] Added Mac OS X Textbox Go-side implementation. Doesn't quite work yet. --- objc_darwin.h | 2 +- textbox_darwin.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 textbox_darwin.go diff --git a/objc_darwin.h b/objc_darwin.h index d845a67..fec0b67 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -79,7 +79,7 @@ extern id newLabel(void); extern id newGroup(id); extern const char *groupText(id); extern void groupSetText(id, char *); -extern id newTextbox(id); +extern id newTextbox(void); extern char *textboxText(id); extern void textboxSetText(id, char *); diff --git a/textbox_darwin.go b/textbox_darwin.go new file mode 100644 index 0000000..0ad47f6 --- /dev/null +++ b/textbox_darwin.go @@ -0,0 +1,33 @@ +// 24 october 2014 + +package ui + +import ( + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +type textbox struct { + *scroller +} + +func newTextbox() Textbox { + id := C.newTextbox() + t := &textbox{ + scroller: newScroller(id, true), // border on Textbox (TODO confirm type) + } + // TODO preferred size + return t +} + +func (t *textbox) Text() string { + return C.GoString(C.textboxText(t.id)) +} + +func (t *textbox) SetText(text string) { + ctext := C.CString(text) + defer C.free(unsafe.Pointer(ctext)) + C.textboxSetText(t.id, ctext) +}