I have a working NSTextView. It does show some text and when it sees a URL, it shows a hyperlink with blue foreground color. So far so good.
Now I am interested in showing a custom color for the URL. So I am setting another attribute NSForegroundcolor. I noticed that when I set NSLinkAttributeName, it will always override the custom color with default blue color. If I remove the NSLinkAttributeName, it will show the link with the custom color. As soon as I add NSLinkAttributeName back, it turns back to default blue.
Set the NSTextView's linkTextAttributes to your foreground color.
Related
I am subclassing NSDatePicker to implement calendar widget. I am able to change text color by setting textColor property of NSDatePicker but when I click on any field of NSDatePicker like Month/Year/Day the default color is somewhat blue.
I want to change highlight color to some custom color but I am not able to do that. I tried overriding highlightColorWithFrame:inView: and highlight:withFrame:inView: but no effect.
This is how it looks at present
I would not recommend to change the selection color of a control since maxOS Mojave will allow the user to customise the Accent color in system preferences.
If ever you are still looking for customisation you must customise the drawing of the NSDatePickerCell and not of the control itself. I would try to overwrite
draw(withFrame cellFrame: NSRect, in controlView: NSView)
but for NSDatePickerCell it may be some more difficult since there are multiple datePicker elements.
I clicked on the foreground/background little square tool icons, selected the color I want and clicked ok. The small tool icon is showing the new color but the image itself hasn't changed the color. And yes confirmed that the mode is RGB.
You need to use a tool to apply the color as needed...
Did you use the paint bucket or brush to actually add the new color to the image?
Simply changing the color of this box does not change the foreground background color automatically
First Off, I found this extremely useful page on theme brushes:
http://metro.excastle.com/xaml-system-brushes
So Roughly, on startup for WinRT/XAML I am setting my theme brush for a textbox in a stylesheet:
Foreground = TextBoxDisabledForegroundThemeBrush
Background = TextBoxDisabledBackgroundThemeBrush
Which at run time makes the textbox appear as: white border, transparent background and grey text. Which I was hoping it would make it transparent, white border and white text.
On my Tapped event, I change the textbox to:
Foreground = TextBoxButtonPressedForegroundThemeBrush
Background = TextBoxButtonPressedForegroundThemeBrush
Which is supposed to be black background, white text and white border. Which seems right, but the cursor is back and you cannot see it.
First question is, am I doing this right to change my text color? I want to change the textbox so once it is selected it stays a changed color. I think this is correct. But I am not sure if I should be setting Foreground or maybe a Font Style instead?
Unfortunately you can't change caret color so if you want your TextBox editable - you should keep the background white or otherwise light. Otherwise, controlling the look of your control in its various states is best done using VisualStateManager and that is easiest to manipulate using Blend.
I have a NSSearchField and I want to change its background color but i am not able to do it i tried out few things:
1) I tried to set DrawBackground TRUE and then setBackgroundColor but the value of DrawBackGround is always False either I try to set it trough code or Nib.(i don't know why?)
2)I tried out setting NSText's BackgroundColor but it is not looking good because it is not covering whole NSSearchField the extreme corners where the small search icon and cancel icon is present are left uncolored.
3)I want the searchField to have the color of the view it is lying so i decreased the alpha value of the searchField which looks good but the alpha value of text is also decreased so is there any way to make text's alpha value to remain always 1.
Thanks :)
If you look at the documentation, Apple prevents background color rendering for rounded-rectangle fields:
"In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields."
https://developer.apple.com/library/prerelease/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextField_Class/#//apple_ref/occ/instm/NSTextField/setDrawsBackground:
NSSearchField is extension of NSTextField, NSTextField again extension of NSView,
Not sure, but its possible to make a custom clas and overwrite drawRect function and paint with the background color.
I am trying to develop a editor, for that i want to set color of button according to selected color from the color panel.button is NSToolBarItem...How can I do it???
Subclass NSBarButtonItem and override the drawRect method based on the currently selected color.