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 7986767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:56:51+00:00 2026-06-04T11:56:51+00:00

When editing code, Xcode is capabale of displaying in-text controls, like drop down buttons

  • 0

When editing code, Xcode is capabale of displaying in-text controls, like drop down buttons which can show context menu’s. I’ve seen other OS X apps that handle text capable of similar features. See the attached sample.

enter image description here

I presume this effect is obtained using NSTextAttachmentCell – although I’m not sure whether this is the proper way to implement this.

For my own app I would like to use this technique as well.

I have the following questions:

  • Is NSTextAttachmentCell the correct way to implement such a feature? If not, what would be?

  • How do I attach a control -comparable to the one in the above sample- to a specific range of text so that its location within NSTextView is dynamic and follows layout actions?

I found this which gives some hints but does not cover the attachment to specific text ranges.

  • 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-04T11:56:52+00:00Added an answer on June 4, 2026 at 11:56 am

    Although NSTextAttachmentCell will work, it has a disadvantage: the cell will become just a glyph in the text which was not what I wanted. It distorts the layout of the text, is selectable etc. I wanted the cell to be drawn over the text, just like the behaviour in Xcode.

    The challenge was to find a way of translating a point from a Mouse Moved event to the position of a particular string of characters inside the NSTextView.

    After some more digging I found a little gem in Apple’s demo apps called LayoutManagerDemo. This demo shows a custom subclass of NSTextView capable of highlighting individual characters, words and lines while the mouse is hoovering its view. From there on it was pretty easy to fade in a button at the required NSPoint and then show a popup menu with some options.

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

Sidebar

Related Questions

I'd like to use Vim for editing sources and Xcode for all other purposes
I am using the DreamEdit (source code editing) component (of which I have a
I use emacs for viewing and editing code and other text files. I wanted
So, I like to use TextWrangler for editing code in OSX, and I tend
When in Xcode editing code for my objective C files, I often press Command-F
I've gone editing code -> which is never a good thing! the code is
I have created a fonts and colors theme for code editing in XCode 4.3
In Eclipse, editing Java code, if I type an open-paren, I get a pair
I was just editing some C# code between <% %> tags in an .ascx
I use Notepad++ and Aptana for editing my CakePHP code? Is there any way

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.