Skip to content

Instantly share code, notes, and snippets.

View pilky's full-sized avatar

Martin Pilkington pilky

View GitHub Profile
@pilky
pilky / SourceListTableCellView.swift
Created July 6, 2020 19:06
A source list cell that correct colours the label text of a drag image when selected
class SourceListTableCellView: NSTableCellView {
override var draggingImageComponents: [NSDraggingImageComponent] {
let components = super.draggingImageComponents
guard
self.backgroundStyle == .emphasized, //emphasized = selected
let textField = self.textField,
let newStyle = textField.attributedStringValue.mutableCopy() as? NSMutableAttributedString,
let labelIndex = components.firstIndex(where: { $0.key == .label })
else {
return components
--indent 4
--self insert
--extensionacl on-declarations
--modifierorder required,dynamic,override,public,private,private(set),lazy
--ranges no-space
--patternlet inline
--disable consecutiveBlankLines, strongOutlets, blankLinesAroundMark, unusedArguments
--disable spaceInsideComments, redundantParens, andOperator, consecutiveSpaces, redundantReturn
--disable indent, redundantNilInit, redundantType, redundantObjc, enumNamespaces