Professional Web Applications Themes

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

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 ...

  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. #2

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

    [email]slavinshearsay.demon.co.uk[/email]localhost (Simon Slavin) wrote in message news:<BB8AAFF796683D2CE010.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

  3. #3

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

    In article <50052383.0309142349.51f927f2posting.google.com >,
    [email]christian.wittepost.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

Similar Threads

  1. change color of cells at hover
    By fister in forum Macromedia Dynamic HTML
    Replies: 9
    Last Post: March 7th, 07:25 PM
  2. Change the first number
    By EdmondsM in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: July 26th, 11:54 AM
  3. Replies: 1
    Last Post: February 18th, 11:41 AM
  4. _Help: Batch Printing PDFs -- How to Change Target Folder
    By Adamo in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: May 13th, 10:31 PM
  5. Cocoa: detecting click in NSMatrix
    By Simon Slavin in forum Mac Programming
    Replies: 0
    Last Post: September 7th, 11:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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