NSTextField clicked link colour - macos

I have an NSTextField that contains an NSAttributedString which itself contains a clickable link.
I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this?

Seems that I'm not the only one with this problem, and there's a handy class to solve it:
https://github.com/laevandus/NSTextFieldHyperlinks
https://github.com/catlan/DSClickableURLTextField

This (http://developer.apple.com/library/mac/#qa/qa1487/_index.html) may help you. It will show you how to set/change the blue link color and the underlineAttribute. You may also have a look at the methods -linkTextAttributes and -setLinkTextAttributes: of an NSTextView.

Related

NSPopupButton with color well

Some of the color selection buttons in the Xcode details panels are a NSPopupButton with a color well. It looks something like a segmented control/popup button.
Placing a standard color well and standard popup button next to each other doesn't have the same look. Also, the menu wouldn't cover the color well in this case. The popup image (two triangles) is not readily available for a custom control either.
Anyone tried to make a similar control before? Any hints on how to make it?

Strange NStextfield drawing behaviour

I'm using NSTextField in OSX, why text fields used are inconsistent, Some of them are rectangle perfectly while some of them have corner ? Please see attached screenshot.
I want it to be all square perfectly. I've already checked in IB they seems to have same attributes.
Anyone have ideas?

Remove border from NSScrollView/NSCollectionView

As you can see in the screenshot below, the NSCollectionView I used has some kind of border (the thin gray lines) I want to get rid of. Can somebody tell me how to achieve this? I already tried subclassing the NSCollectionView and tried to overwrite it in the drawRect: by using [[super layer] setBorderWidth:0.0f]; but this did not work.
Searching on Google, SO and the Apple Documentation did not help either. So did anyone achieved this already or knows where I can find an example of how to do it?
Thanks in advance,
Björn
The collectionView is nested in a NSScrollView, which has a borderType property.
You can get rid of the border by simply setting its border type to NSNoBorder.
self.collectionView.enclosingScrollView.borderType = NSNoBorder;
From story board:
Select the scroll view from story board
Then choose no boarder from Attributes Inspector
For Swift 3 :-
collectionView.enclosingScrollView?.borderType = .noBorder

Interface Builder change text color bug?

This is driving me bananas..
If I select a UITextField in interface builder and go to change the text colour by manually entering the R G B values it changes the colour of the entire frame and background.
However if I change it using the sliders it changes the text colour only like I want.
Leads me to think its a bug... does this happen for anyone else?
I see this happening with the latest version of Xcode as well. Both the Text Color and Background Color controls in the UILabel attribute inspector change at the same time when manually typing in a R G B value, whereas if I choose a color another way (e.g. from the crayons or palette views in the Color picker), only the text color control value changes.
I'd assume this is a bug (and should be filed via http://bugreporter.apple.com), but then again it's persisted through a few versions of Xcode so this may be their expected behavior on purpose. But I'd definitely agree you should file it as a bug.
Definitely a bug! A temporary solution is to double click the text on the UILabel i.e. selecting all the UILabel text in the UI (storyboard or xib). Only so using the sliders changes the text colour. Hope it helps
Or change the color and then set the background color back to transparent. For me the fastest workaround. Same bug with UILabel.
You can try selecting the text you want to change the color of, then click T to open the fonts window and change the color from there. Working for me on Xcode 11.2.1.

Table view cell, custom editor and editing frame

I am using a custom editor when editing the contents of a cell inside a Table view. From the docs I see that the custom editor has to be an NSTextView. So I put the text view in the document view, then I referenced it from the cell subclass through an IBOutlet in order to assign it as custom editor.
When doing all this, I can set the editor not to draw its background, but a thick white border is shown when the user edits that cell, and there is no way to remove it.
So I create the NSTextView programmatically, assigned it as the custom editor, and no white border is shown, but I can't change the background now, set it to clearColor, set the font, fontColor etc. I can't do anything with it. It is just a square with dark background and white text.
Is there something I am not doing? This is a bad approach?
Thank you.
The border is drawn by drawRect:, but I still don't know how to fix it by overriding drawRect:...
You may have a look at this link: http://www.cocoabuilder.com/archive/cocoa/129091-solved-re-disabling-nstableview-big-black-editing-box.html#129259

Resources