NSCell editing weirdness

  • Hi all,

    I've subclasses NSTextFieldCell to experiment implementing
    editWithFrame but the method never gets called! Here's the code which
    I'm using to set the cell up:

    NSCell* c = [[DACell alloc] initTextCell:@""];
    [c setEditable:YES];
    [[[table tableColumns] objectAtIndex:0] setDataCell:c];

    and i've overridden editWithFrame like this

    - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
    editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)
    theEvent {
    NSLog(@"editing");
    [super editWithFrame:aRect inView:controlView editor:textObj
    delegate:anObject event:theEvent];
    }

    but it never gets called. Hmmm what am I doing wrong?

    Regards,
    David
  • I've found that the selectWithFrame equivalent is often called when
    the editWithFrame is what you'd expect. Try overriding that method
    instead. You can accomplish the same function with it.

    -Phil

    On Oct 3, 2006, at 9:22 PM, David Aames wrote:

    > Hi all,
    >
    > I've subclasses NSTextFieldCell to experiment implementing
    > editWithFrame but the method never gets called! Here's the code
    > which I'm using to set the cell up:
    >
    > NSCell* c = [[DACell alloc] initTextCell:@""];
    > [c setEditable:YES];
    > [[[table tableColumns] objectAtIndex:0] setDataCell:c];
    >
    > and i've overridden editWithFrame like this
    >
    > - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
    > editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)
    > theEvent {
    > NSLog(@"editing");
    > [super editWithFrame:aRect inView:controlView editor:textObj
    > delegate:anObject event:theEvent];
    > }
    >
    > but it never gets called. Hmmm what am I doing wrong?
    >
    > Regards,
    > David
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<dev...>
    >
    > This email sent to <dev...>
    >
  • I've also overridden the selectWithFrame: too but still it isn't
    called. TBH I'm just fed up and I have no ideas what to do...

    Regards,
    David

    On 3 Oct 2006, at 22:09, Philip Dow wrote:

    > I've found that the selectWithFrame equivalent is often called when
    > the editWithFrame is what you'd expect. Try overriding that method
    > instead. You can accomplish the same function with it.
    >
    > -Phil
    >
    > On Oct 3, 2006, at 9:22 PM, David Aames wrote:
    >
    >> Hi all,
    >>
    >> I've subclasses NSTextFieldCell to experiment implementing
    >> editWithFrame but the method never gets called! Here's the code
    >> which I'm using to set the cell up:
    >>
    >> NSCell* c = [[DACell alloc] initTextCell:@""];
    >> [c setEditable:YES];
    >> [[[table tableColumns] objectAtIndex:0] setDataCell:c];
    >>
    >> and i've overridden editWithFrame like this
    >>
    >> - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
    >> editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)
    >> theEvent {
    >> NSLog(@"editing");
    >> [super editWithFrame:aRect inView:controlView editor:textObj
    >> delegate:anObject event:theEvent];
    >> }
    >>
    >> but it never gets called. Hmmm what am I doing wrong?
    >>
    >> Regards,
    >> David
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/<dev...>
    >>
    >> This email sent to <dev...>
    >>
    >
  • On Tue, 3 Oct 2006 23:05:41 +0100, David Aames <aamesster...>
    said:
    > I've also overridden the selectWithFrame: too but still it isn't
    > called. TBH I'm just fed up and I have no ideas what to do...

    Lose the attitude and try again. I just did exactly what you said, i.e.:

        NSCell* c = [[OtherCell alloc] initTextCell:@""];
        [c setEditable:YES];
        [[[myTableView tableColumns] objectAtIndex:0] setDataCell:c];

    and, in OtherCell:

    - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView
    editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart
    length:(int)selLength {
        NSLog(@"selecting");
        [super selectWithFrame:aRect inView:controlView editor:textObj
    delegate:anObject start:selStart length:selLength];
    }

    and selectWithFrame: *is* called. m.

    > On 3 Oct 2006, at 22:09, Philip Dow wrote:
    >
    >> I've found that the selectWithFrame equivalent is often called when
    >> the editWithFrame is what you'd expect. Try overriding that method
    >> instead. You can accomplish the same function with it.
    >>
    >> -Phil
    >>
    >> On Oct 3, 2006, at 9:22 PM, David Aames wrote:
    >>
    >>> Hi all,
    >>>
    >>> I've subclasses NSTextFieldCell to experiment implementing
    >>> editWithFrame but the method never gets called! Here's the code
    >>> which I'm using to set the cell up:
    >>>
    >>> NSCell* c = [[DACell alloc] initTextCell:@""];
    >>> [c setEditable:YES];
    >>> [[[table tableColumns] objectAtIndex:0] setDataCell:c];
    >>>
    >>> and i've overridden editWithFrame like this
    >>>
    >>> - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
    >>> editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)
    >>> theEvent {
    >>> NSLog(@"editing");
    >>> [super editWithFrame:aRect inView:controlView editor:textObj
    >>> delegate:anObject event:theEvent];
    >>> }
    >>>
    >>> but it never gets called. Hmmm what am I doing wrong?
    >>>
    >>> Regards,
    >>> David
    >>> _______________________________________________
    >>> Do not post admin requests to the list. They will be ignored.
    >>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>> Help/Unsubscribe/Update your Subscription:
    >>> http://lists.apple.com/mailman/options/cocoa-dev/<dev...>
    >>>
    >>> This email sent to <dev...>
    >>>
    >>
    >
    >
    >
    >

    --
    matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    A fool + a tool + an autorelease pool = cool!
    AppleScript: the Definitive Guide - Second Edition!
    <http://www.amazon.com/gp/product/0596102119>
previous month october 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 31          
Go to today