Cocoa: NSMatrix, change number of cells, can't target new ones

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Cocoa: NSMatrix, change number of cells, can't target new ones

    I have an NSMatrix of buttons. They work fine and the target
    is called when I click on one of them. I've set it up as just

    - (IBAction)itemClick:(id)sender

    and my routine get called fine.

    Now I need to change the number of cells in the matrix. In
    fact I change the number several times, sometimes more, some-
    times less. There is a maximum possible number but it's in the
    hundreds. Changing the number works fine: the new cells are
    drawn correctly and they highlight when I click on them.

    Naturally, when I add new cells I also want them to call the
    target routine. I tried to do this by using the first cell
    to find its target, then setting the target of the other cells
    to the same thing:

    currentCell = [theMatrix cellAtRow:0 column:0];
    theTarget = [currentCell target];
    [...]
    iterate through the cells:
    [currentCell setTarget:theTarget];
    end iteration

    I know my iteration works because it sets other properties at
    the same time. But none of the setTargets works. The top
    few cells still call the routine but none of the new ones does.

    What am I doing wrong ?


    Simon Slavin Guest

  2. Similar Questions and Discussions

    1. change color of cells at hover
      I want to build a navigation , without graphics, where the cell containing the link changes color when hovered over. I have applied a css style to...
    2. Change the first number
      Hi All, I have a list of ID numbers that are populated in from a query into a cfselect. The numbers start a 1, but 1 is a fixed field that will...
    3. Why doesn't the CssClass property change the visual display of my datagrid cells?
      Why doesn't the CssClass property change the visual display of my datagrid cells? Thanks for any insights. I'm primarily a developer of .NET...
    4. _Help: Batch Printing PDFs -- How to Change Target Folder
      _Help: Batch Printing PDFs -- How to Change Target Folder I am batch printing multiple documents to PDF and want to print each PDF to the...
    5. Cocoa: detecting click in NSMatrix
      Okay, how the hell am I meant to do this ? I've set an IBAction as the target for my matrix and my routine does actually get called when the user...
  3. #2

    Default Re: Cocoa: NSMatrix, change number of cells, can't target new ones

    [email]slavins@hearsay.demon.co.uk[/email]@localhost (Simon Slavin) wrote in message news:<BB8AAFF796683D2CE0@10.0.1.2>...
    > currentCell = [theMatrix cellAtRow:0 column:0];
    > theTarget = [currentCell target];
    > [...]
    > iterate through the cells:
    > [currentCell setTarget:theTarget];
    > end iteration
    >
    > I know my iteration works because it sets other properties at
    > the same time. But none of the setTargets works. The top
    > few cells still call the routine but none of the new ones does.
    >
    > What am I doing wrong ?
    you have to set the action too:

    [currentCell setAction:@selector(itemClick:)];

    Ciao

    Christian
    Christian Witt Guest

  4. #3

    Default Re: Cocoa: NSMatrix, change number of cells, can't target new ones

    In article <50052383.0309142349.51f927f2@posting.google.com >,
    [email]christian.witt@epost.de[/email] (Christian Witt) wrote:
    >you have to set the action too:
    >
    >[currentCell setAction:@selector(itemClick:)];
    Thank you thank you thank you. Somehow I didn't think of that.
    I had target and action confused. That fixed it perfectly.
    >Ciao
    Mille Gracie.
    >Christian
    Oh. Herslichen Danke ?


    Simon Slavin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139