Setting matrix cell state

Discussion in 'Mac Programming' started by Dreamspinner, Feb 19, 2013.

  1. macrumors member

    Joined:
    Dec 17, 2012
    #1
    I have an NSMatrix as 2 radio buttons( 1 col, 2 rows). I need to be able to set one to selected (ON, checked) state. The matrix and both cells have an action which fires when one of the buttons is clicked. The matrix has an outlet, but the cells do not. In the code below, I get the correct tag, but none of the other lines (tried one at a time) have any effect.

    Code:
    - (IBAction)matrixClick:(id)sender
    {
      id theCell = [sender selectedCell];
      int theTag = [theCell tag];
    
      [[matrixRotor cellAtRow:0 column:0] setState:1];
      [matrixRotor selectCellWithTag:1];
      [matrixRotor  setState:1 atRow:0 column:0];
      NSLog(@"Setting RB");
    }
    
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Have you checked everything including the obvious? For example have you checked that matrixRotor is not nil? Also don't use 1, use NSOnState
     
  3. thread starter macrumors member

    Joined:
    Dec 17, 2012
    #3
    I don't have a list of 'everything', so no, I haven't. Wouldn't 'the obvious' be a subset of everything? :)

    Seriously, I don't know what else I can check. I put in a test for nil, and it's not.
    The use of NSOnState made no difference.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    OK, matrixRotor is not nil. That's a good start. What sort of cell are you using?
     
  5. thread starter macrumors member

    Joined:
    Dec 17, 2012
    #5
    As I said in the OP, radio buttons.
     
  6. thread starter macrumors member

    Joined:
    Dec 17, 2012
    #6
    Sorted. You can't change state in a method that responds to a click event of a button. Moved it elsewhere.
     
  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    Cool. I suppose that makes some sense. The click itself should be changing the state anyway
     

Share This Page