summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-26 21:54:14 -0400
committerPietro Gagliardi <[email protected]>2014-06-26 21:54:14 -0400
commit20821c26eb32b4f5772cf3e2ba13d36d424731c3 (patch)
treebe0e5f8df602f064a9a0633b10dec9fe437ec075
parentebbd76716f3e35bdb86a6ca9b327bc014d7f6e3b (diff)
Implemented Checkbox.SetChecked() on Mac OS X and updated the README.
-rw-r--r--README.md5
-rw-r--r--objc_darwin.h1
-rw-r--r--sysdata_darwin.go10
-rw-r--r--sysdata_darwin.m10
4 files changed, 24 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4de00a4..ff8f5f4 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,9 @@ Woah, lots of attention! Thanks!
## Updates
- **26 June 2014**
- - Controls in Windows can now be spaced apart more naturally. Call `w.SetSpaced(true)` to opt in. **Whether this will remain opt-in or whether the name will change is still unknown at this point.**
- - There's a new function `Layout()` which provides high-level layout creation. The function was written by [boppreh](https://github.com/boppreh) and details can be found [here](https://github.com/andlabs/ui/pull/19). **Whether this function will stay in the main package or be moved to a subpackage is still unknown.**
+-- Controls in Windows can now be spaced apart more naturally. Call `w.SetSpaced(true)` to opt in. **Whether this will remain opt-in or whether the name will change is still unknown at this point.**
+-- There's a new function `Layout()` which provides high-level layout creation. The function was written by [boppreh](https://github.com/boppreh) and details can be found [here](https://github.com/andlabs/ui/pull/19). **Whether this function will stay in the main package or be moved to a subpackage is still unknown.**
+-- There is now `Checkbox.SetChecked()` to set the check state of a Checkbox programmatically.
- **25 June 2014**<br>Labels by default now align themselves relative to the control they are next to. There is a new function `NewStandaloneLabel()` which returns a label whose text is aligned to the top-left corner of the alloted space regardless.
diff --git a/objc_darwin.h b/objc_darwin.h
index 87acea2..22bafb1 100644
--- a/objc_darwin.h
+++ b/objc_darwin.h
@@ -123,6 +123,7 @@ extern void windowSetContentSize(id, intptr_t, intptr_t);
extern void setProgress(id, intptr_t);
extern void setAreaSize(id, intptr_t, intptr_t);
extern void center(id);
+extern void setCheckboxChecked(id, BOOL);
/* combobox_darwin.m */
extern id makeCombobox(BOOL);
diff --git a/sysdata_darwin.go b/sysdata_darwin.go
index 26bcd98..48b7d44 100644
--- a/sysdata_darwin.go
+++ b/sysdata_darwin.go
@@ -422,3 +422,13 @@ func (s *sysData) center() {
}
<-ret
}
+
+func (s *sysData) setChecked(checked bool) {
+ ret := make(chan struct{})
+ defer close(ret)
+ uitask <- func() {
+ C.setCheckboxChecked(s.id, toBOOL(checked))
+ ret <- struct{}{}
+ }
+ <-ret
+}
diff --git a/sysdata_darwin.m b/sysdata_darwin.m
index 1119255..fc1f270 100644
--- a/sysdata_darwin.m
+++ b/sysdata_darwin.m
@@ -228,3 +228,13 @@ void center(id w)
{
[toNSWindow(w) center];
}
+
+void setCheckboxChecked(id checkbox, BOOL check)
+{
+ // -[NSButton setState:] takes a NSInteger but the state constants are NSCellStateValue which is NSUInteger (despite NSMixedState being -1); let's play it safe here
+ if (check) {
+ [toNSButton(checkbox) setState:NSOnState];
+ return;
+ }
+ [toNSButton(checkbox) setState:NSOffState];
+}