I have a field editor which I need to reposition in my tableView – specifically, I need to move it a few pixels to the right. The following post:

http://www.cocoabuilder.com/archive/message/cocoa/2009/3/16/232513

makes two suggestions: (i) implement the move in -viewWillDraw in the field editor subclass, and (ii) reposition the field editor after calling super in -editColumn:row:withEvent:select: in the tableView subclass. Neither of these seem to make any difference to where the field editor is drawn. Here is my code with respect to (i), contained in the field editor subclass:

-(void)viewWillDraw
{
        NSRect frame = [self frame];
        NSLog(@"Old: %f",frame.origin.x);
        frame.origin.x += 50.0;
        [self setFrame:frame];
        frame = [self frame];
        NSLog(@"New: %f",frame.origin.x);

        [super viewWillDraw];
}

Now, I can confirm this method is being called, and by means of the NSLog statements, the frame is being changed prior to the call to super. Unfortunately, the field editor is drawn where is usually is drawn, with no shift in place.

With respect to (ii), contained in the tableView subclass:

-(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag
{
[super editColumn:columnIndex row:rowIndex withEvent:theEvent select:flag];
        NSText *fieldEditor = [[self window] fieldEditor:YES forObject:self];
        NSRect fieldEditorFrame = [fieldEditor frame];
        fieldEditorFrame.origin.x += 50.0;
        [fieldEditor setFrame:fieldEditorFrame];
}

Here, it turns out that even though fieldEditor points to the custom field editor object, fieldEditorFrame turns out to be empty. And again, the field editor is drawn where it is usually drawn, with no shift in place.

Any help would be greatly 
appreciated._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to