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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:51:29+00:00 2026-05-23T09:51:29+00:00

I am trying to draw some text that is clickable. I am trying not

  • 0

I am trying to draw some text that is clickable.
I am trying not to use NSButton as my text is being drawn in drawRect and using NSButton in a drawRect makes it add the subview on top of itself unless you go through and remove all subviews on each call of drawRect.

I tried creating a NSButton and instead of adding it as a subview I am calling [myBtn.cell drawTitle: withFrame: inView:] which draws the text, but it is not clickable.

Is there a way to draw text (in a way like using drawInRect) but where I can also have the text be clickable?

If not, what would you recommend? Using a standard NSButton and clearing all the subviews each time?

  • 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-05-23T09:51:30+00:00Added an answer on May 23, 2026 at 9:51 am

    One way I’ve seen this done before is to use an NSAttributedString. The part that’s clickable should be changed somehow (ie, have a different NSForegroundColorAttributeName and NSUnderlineStyleAttributeName) and then attach the NSURL to it with the NSLinkAttributeName.

    If I remember correctly, I believe this is an NSTextField subclass that does this: DSClickableURLTextField / Swift DSClickableURLTextField fork

    I would recommend not drawing the text yourself, because there are lots of things in AppKit that will do this for you. Why do you need to draw it yourself?

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

Sidebar

Related Questions

I'm trying to render some text using PIL, but the result that comes out
I'm trying to draw text using Core Text functions, with a line spacing that's
I am trying to use the HTML5 canvas element to draw some arcs and
I am trying to draw a series of rectangles using OpenGL but some of
I'm trying to draw the pages of a PDF using the code below. Some
I am trying to write some code that that will draw the line which
I'm trying to draw text with some part of it in different color First
I've got a little text drawing puzzle under Win32. I'm trying to draw some
I'm trying to use a custom textfield background. The problem is that the text
I'm trying to draw some text on the iPhone, but in landscape mode, where

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.