Implemented Checkbox.SetChecked() on Mac OS X and updated the README.

This commit is contained in:
Pietro Gagliardi 2014-06-26 21:54:14 -04:00
parent ebbd76716f
commit 20821c26eb
4 changed files with 24 additions and 2 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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
}

View File

@ -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];
}