Posts

Post not yet marked as solved
7 Replies
1.7k Views
I am trying to understand how an NSTextField reacts to changes of its cell's backgroundStyle.The reason is that I want to use the automatic handling of the text color be used when I set the backgroundStyle of the text field that's inside a table cell.From what I have gathered so far, the textfield's cell has a backgroundStyle property and when this is set, and the textColor is `labelColor` (or any of the other control colors) the text color should be automatically updated to be fitting for the backgroundStyle.Given a tableView with a custom row class and a custom cell:class RowView: NSTableRowView { override func drawSelection(in dirtyRect: NSRect) { if isSelected { NSColor.white.set() var rects: UnsafePointer<NSRect>? = nil var count: Int = 0 self.getRectsBeingDrawn(&rects, count: &count) for i in 0..<count { let rect = NSIntersectionRect(bounds, rects![i]) __NSRectFillUsingOperation(rect, NSCompositingOperation.sourceOver) } } } override var interiorBackgroundStyle: NSView.BackgroundStyle { return isSelected ? .light : .dark } }andclass CustomCellView: NSTableCellView { @IBOutlet weak var label: NSTextField! override var backgroundStyle: NSView.BackgroundStyle { didSet { Swift.print("Style set to \(backgroundStyle == .light ? "light" : "dark")") Swift.print("Label Style set to \(label.cell!.backgroundStyle == .light ? "light" : "dark")") } } }I would expect the label to be drawn in black, when I select the row.I can see that the backgroundStyle is forwarded correctly when I select the row, but the label doesn't change color at all. In fact, being seemingly blended with my white selection, the label disappears entirely.Why is the label color not changing?P.S.: I know that I can manually set the label's color based on the background style of the cell. That's not what I am asking. I want to use the convenience of the `controlTextColor`s or at least understand why they are not working in this case. (They do seem to work if I don't draw my custom selection in the row and use the standard blue selection)
Posted
by tkrajacic.
Last updated
.
Post marked as solved
5 Replies
609 Views
I am using runtime loaded dynamic libraries (in an NSBundle) as a plugin system in my app.I would like to switch over to using XPC Services though, for various reasons. Is it possible to load plugins which are really xpc services from a user-specified folder? I have not yet figured out how I would go about dicovering that a plugin is present or put in the PlugIns folder.That folder would most likely be either under ~/Documents/MyApp/PlugIns or something else user-accessible.(I may also ship some plugins with the app, which are inside the app's bundle, but discovering/loading those seems trivial)Thank you for your help.Thomas
Posted
by tkrajacic.
Last updated
.
Post not yet marked as solved
0 Replies
490 Views
// GivenI have a framework that uses a custom file extension (it is used as a runtime loaded plugin usually, so something like ".plugin" looks nice)// WhenNow I want to write unit tests for some internal parts of this plugin, so I add a unit test bundle to my plugin's project in Xcode.// ThenThe problem is that the unit test can't import the module of the plugin, as it can't find frameworks that don't have a .framework extension.Is there a way to teach the loader to also check other extensions?(If I change the "wrapper extension" build setting back to "framework" everything works, but that's not what I want)I guess a similar problem would arise when I want to write unit-tests for an XPC service?
Posted
by tkrajacic.
Last updated
.