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

  • Home
  • SEARCH
  • 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 8237091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:21:25+00:00 2026-06-07T19:21:25+00:00

Cocoa newbie here: and I seem to be getting into all the really arcane

  • 0

Cocoa newbie here: and I seem to be getting into all the really arcane stuff first. I wanted an NSTextField in which the contents were selected by default when clicked, and in which I could change the selection color. I found enough on this forum to get me started in the mysteries of field editors. I have NSTextField subclassed, and the becomeFirstResponder method overridden:

- (BOOL) becomeFirstResponder {
    if (!super.becomeFirstResponder) return NO;
    NSTextView * fieldEditor = (NSTextView *) [self.window fieldEditor:YES forObject:self];
    [fieldEditor performSelector:@selector(selectAll:) withObject:fieldEditor afterDelay:0];
    [fieldEditor setSelectedTextAttributes:selectionColor];
    return YES; }

Where selectionColor is a one-item NSDictionary with an NSColor object keyed to NSBackgroundColorAttributeName. This works perfectly for text fields on windows and panels, but doesn’t work at all for fields in the view of an NSPopover. In fact, it makes text selection impossible. It is still possible to click in the field and type, but dragging the cursor through text to select it fails. I can only conclude I’m misconfiguring the field editor somehow. Am I referencing it correctly?

  • 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-07T19:21:27+00:00Added an answer on June 7, 2026 at 7:21 pm

    I hope I’m following stackOverflow protocol in answering my own question. The short answer is that, apparently, the code I posted works perfectly well for NSPopovers. The probable reason I thought it wasn’t working was that the NSDictionary object I called selectionColor wasn’t being correctly initialized. I’m having an Emily Litella moment here: “Oh… Never mind!” The only problem now, as I see it, is that it took me a ridiculous amount of time to track this one down.

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

Sidebar

Related Questions

I am new to Cocoa and wanted to develop an app which can use
Cocoa newbie here... I know this sounds stupid but I can't find the Bindings
Cocoa newbie here. I am working on an iPhone UITableViewController-based widget that can be
I'm a newbie Cocoa developer and I'm developing my first application. I want to
Please keep in mind that I'm a really newbie Cocoa developer Scenario: I've a
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
Disclaimer: Cocoa newbie here. I wrote an app with a Cocoa GUI that acts
REAL newbie here to Objective C and Cocoa. I have this 'if statement' if
Cocoa's NSScrollView is horribly under-explained. I hope someone here knows what it's all about
Hey, Im a newbie in cocoa and I have a string and I am

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.