ui/cocoa/button.m

changeset 568
797b73c2c883
parent 566
0e0e9035c6c7
child 603
8d2b7b934230
equal deleted inserted replaced
567:4ee3e4ce03ad 568:797b73c2c883
250 int64_t ui_radiobuttons_get(UiInteger *i) { 250 int64_t ui_radiobuttons_get(UiInteger *i) {
251 NSMutableArray *buttons = (__bridge NSMutableArray*)i->obj; 251 NSMutableArray *buttons = (__bridge NSMutableArray*)i->obj;
252 int64_t index = 0; 252 int64_t index = 0;
253 for(UiRadioButton *b in buttons) { 253 for(UiRadioButton *b in buttons) {
254 if([b cell].state != 0) { 254 if([b cell].state != 0) {
255 i->value = index; 255 i->value = index + 1;
256 break; 256 break;
257 } 257 }
258 index++; 258 index++;
259 } 259 }
260 return index; 260 return i->value;
261 } 261 }
262 262
263 void ui_radiobuttons_set(UiInteger *i, int64_t value) { 263 void ui_radiobuttons_set(UiInteger *i, int64_t value) {
264 NSMutableArray *buttons = (__bridge NSMutableArray*)i->obj; 264 NSMutableArray *buttons = (__bridge NSMutableArray*)i->obj;
265 int64_t index = 0; 265 int64_t index = 1;
266 for(UiRadioButton *b in buttons) { 266 for(UiRadioButton *b in buttons) {
267 if(index == value) { 267 if(index == value) {
268 [b cell].state = NSControlStateValueOn; 268 [b cell].state = NSControlStateValueOn;
269 } else { 269 } else {
270 [b cell].state = NSControlStateValueOff; 270 [b cell].state = NSControlStateValueOff;

mercurial