Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:52:35+00:00 2026-06-17T16:52:35+00:00

There seems to be a bug in NSTextField. When the application launches it all

  • 0

There seems to be a bug in NSTextField. When the application launches it all draws correctly. But as soon as I click in the textField the view gets all messed up. To more specific, whenever I type drawRect: gets called but with a smaller rect causing all the problems.

When I select the text it draws correctly again. The only solution is to set the FocusRingType to visible (example: NSFocusRingTypeDefault). But I would like to have it without the ring. Is this possible?

Here is the code I am using:

-(id)initWithFrame:(NSRect)frameRect
{
    self = [super initWithFrame:frameRect];
    if(self)
    {
        // Add a label
        NSTextField *textField = [[NSTextField alloc] initWithFrame:CGRectMake(0, 0, frameRect.size.width, frameRect.size.height)];
        [[textField cell] setPlaceholderString:@"URL or search term..."];
        [textField setTextColor:[NSColor greyColor]];
        [textField setBackgroundColor:[NSColor clearColor]];
        [textField setFont:[NSFont fontWithName:@"Open Sans" size:20]];
        [textField setDrawsBackground:FALSE];
        [textField setBordered:FALSE];
        [textField setFocusRingType:NSFocusRingTypeNone];
        [self addSubview:textField];
    }

    return self;
}

-(void)drawRect:(NSRect)dirtyRect
{
    NSInteger borderWdith =  2;

    // Create the path to the button
    NSBezierPath *aPath = [NSBezierPath bezierPathWithRoundedRect:CGRectMake(borderWdith, borderWdith,
                                                                             dirtyRect.size.width-(borderWdith*2),
                                                                             dirtyRect.size.height-(borderWdith*2))
                                                          xRadius:3 yRadius:3];

    // Fill the button with white
    [[NSColor whiteColor] set];
    [aPath fill];
}

Tricks like setting editable to TRUE/FALSE in drawRect did not work. Also setting to different focusRingTypes in the method failed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:52:36+00:00Added an answer on June 17, 2026 at 4:52 pm

    Okay, so I managed to sort of fix this drawing problem. In the view init method I set a global CGRect variable which was set to the initial frame.

    Each time -(void)drawRect:(CGRect)dirtyRect was called, I overwrote dirtyRect with the global variable.

    Hope this helps anyone. I guess this isn’t the best solution, but works 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There seems to be a bug in a Wordpress PHP function that leaves whitespace
There seems to be a bug in the Java varargs implementation. Java can't distinguish
It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read
There seems to be a similar question to this on here but with the
There seems to be too many attributes/parameters in CSS... I want to know all
There seems to be a bug in IE when cascading dynamic stylesheets. Does anyone
There seems to be a rather annoying bug in MS Expression Web 3 (or
I tested this code in Chrome and there seems to be a bug involving
This may be waaay to specific for SO, but there seems to be a
There seems to be a Bug with the Outer Join statement in SubSonic 3,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.