Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get state of NSButton (CheckBox) from NSMatrix

Why my code changes the state of selected NSButtenCell to NSOnState after first run?

NSButtonCell *b=[[NSButtonCell alloc] init];
b=[self.myMatrix selectedCell];
[self.myMatrix selectCellAtRow:0 column:0];
if (b.state == NSOnState) {
    NSLog(@"State is On");
}else{
    NSLog(@"State is Off");
}

What can I do ?

like image 659
Sajad Garshasbi Avatar asked Jan 29 '26 20:01

Sajad Garshasbi


1 Answers

I'm not sure but did you check whether calling

[self.myMatrix selectCellAtRow:0 column:0];

performs the state change?

The Apple documentation for NSMatrix says:

> If the specified cell is an editable text cell, its text is selected.

So perhaps this method also may change the checkbox state (but I don't know if that may be the issue).


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!