Hi,

Now I'm using a NSTextField instead of NSTexView.

Best,
Nick

Begin forwarded message:

> From: Nick Rogers <roger...@mac.com>
> Subject: custom field editor, no focus ring, no select all
> Date: 30 August 2013 8:23:12 PM IST
> To: Cocoa-dev List List <cocoa-dev@lists.apple.com>
> 
> Hi,
> 
> I am using a custom field editor for a custom table view cell.
> 
> When ever I click on the name field the editor comes into view, but focus 
> ring is not there and select all doesn't work when using keyboard or mouse or 
> programmatically. I want the focus ring to be drawn and want to select all of 
> the previous text so that the user can simply start typing a new name.
> 
> Here's the code snippet from the method doubleClickInTableView:
> 
> 
> NSTextView *boxText = [[NSTextView alloc] initWithFrame:editRect];
> NSTextContainer *textContainer = [boxText textContainer];
> 
> // Set up container
> [textContainer setContainerSize:NSMakeSize(editRect.size.width, 
> NSHeight([boxText frame]))];
> [textContainer setWidthTracksTextView:NO];
> [textContainer setHeightTracksTextView:NO];
> 
> // Set up size attributes
> [boxText setHorizontallyResizable:YES];
> [boxText setVerticallyResizable:NO];
> [boxText setTextContainerInset:NSMakeSize(0, 2)];
> 
> // Set up editing attributes
> [boxText setSelectable:YES];
> [boxText setEditable:YES];
> [boxText setFocusRingType:NSFocusRingTypeDefault];
> 
> // Set up rich text attributes
> [boxText setRichText:NO];
> [boxText setImportsGraphics:NO];
> [boxText setUsesFontPanel:NO];
> [boxText setUsesRuler:NO];
> 
> // Set up colors
> [boxText setDrawsBackground:YES];
> [boxText setBackgroundColor:[NSColor textBackgroundColor]];
> [boxText setTextColor:[NSColor controlTextColor]];
> 
> [boxText setSelectedTextAttributes:aTitleAttributes];
> // And most importantly...
> [boxText setFieldEditor:YES];
> [boxText setDelegate:self];
> 
> [sender addSubview:boxText];
> [boxText display];
> [boxText release];
> 
> [boxText setString:stringDisplayed];
> 
> [boxText sizeToFit];
> [self.window makeFirstResponder:boxText];
> [boxText drawFocusRingMask];
> [boxText selectAll:self];
> 
> I have tried making boxText an ivar and allocating it in awakeFromNib, but 
> still the same result.
> Please help.
> 
> Thanks,
> Nick
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/roger_s1%40mac.com
> 
> This email sent to roger...@mac.com

_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to