Editing NSBrowserCells

  • Hi, I'm trying to set up an editable NSBrowser and have just run up
    against a brick wall. I'm implementing NSCell's  - (void)
    editWithFrame:(NSRect)aRect
    inView:(NSView *)controlView editor:(NSText *)textObj
    delegate:(id)anObject event:(NSEvent *)theEvent method to set up the
    editing. I've decided to initially set the editing to work on a
    double click. The problem is that although the cell text is made
    available for editing it appears white against a white background.
    I've tried to set the colour of the text with
    setUpFieldEditorAttributes:(NSText *)textObj but this doesn's seem to
    work. What does seem to work is to reload the column of the browser
    containing the cell by adding a new cell to the browser or by
    reloading the column in the textDidBeginEditing delegate method. I've
    included the code I've got so far below.

    - (void)handleDoubleClicks:(id)sender
    {
    NSBrowserCell *selectedCell;
        NSRect cellFrame;
        NSMatrix *theMatrix;
        int selectedRow, selectedColumn;
        NSText *fieldEditor;

        selectedCell = [browser selectedCell];
        selectedColumn = [browser selectedColumn];
        selectedRow = [browser selectedRowInColumn:selectedColumn];
        theMatrix = [browser matrixInColumn:selectedColumn];

        cellFrame = [theMatrix cellFrameAtRow:selectedRow column:0];

    fieldEditor = [[browser window] fieldEditor:YES
    forObject:selectedCell];

    [selectedCell setEditable:YES];
    [selectedCell setSendsActionOnEndEditing:YES];
    [selectedCell setUpFieldEditorAttributes:fieldEditor];
    [selectedCell editWithFrame:cellFrame inView:theMatrix
    editor:fieldEditor delegate:self event:nil]
    }

    Any help would be much appreciated!
previous month september 2006 next month
MTWTFSS
        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  
Go to today