diff --git a/checkbox_darwin.m b/checkbox_darwin.m index a1fd61ca..a07a4d0e 100644 --- a/checkbox_darwin.m +++ b/checkbox_darwin.m @@ -76,3 +76,23 @@ void uiCheckboxOnToggled(uiControl *c, void (*f)(uiControl *, void *), void *dat cc.uiOnToggled = f; cc.uiOnToggledData = data; } + +int uiCheckboxChecked(uiControl *c) +{ + uiCheckboxNSButton *cc; + + cc = (uiCheckboxNSButton *) uiControlHandle(c); + return [cc state] == NSOnState; +} + +void uiCheckboxSetChecked(uiControl *c, int checked) +{ + uiCheckboxNSButton *cc; + NSInteger state; + + cc = (uiCheckboxNSButton *) uiControlHandle(c); + state = NSOnState; + if (!checked) + state = NSOffState; + [cc setState:state]; +} diff --git a/test.c b/test.c index a09e4592..e4579b79 100644 --- a/test.c +++ b/test.c @@ -71,7 +71,7 @@ uiControl *spaced; static void setSpaced(uiControl *c, void *data) { // TODO - printf("toggled %d\n", uiCheckboxCheked(spaced)); + printf("toggled %d\n", uiCheckboxChecked(spaced)); } // these will also be used to test if setting checks will trigger events diff --git a/ui.h b/ui.h index ee2c1212..d6b98910 100644 --- a/ui.h +++ b/ui.h @@ -51,6 +51,6 @@ void uiCheckboxSetText(uiControl *, const char *); void uiCheckboxOnToggled(uiControl *, void (*)(uiControl *, void *), void *); int uiCheckboxChecked(uiControl *); // TODO should this trigger an event? -void uiChekboxSetChecked(uiControl *, int); +void uiCheckboxSetChecked(uiControl *, int); #endif