ghostty/macos/Sources/Helpers/NSView+Extension.swift
2024-02-07 21:44:44 +01:00

19 lines
472 B
Swift

import AppKit
extension NSView {
/// Recursively finds and returns descendant views that have the given class name.
func descendants(withClassName name: String) -> [NSView] {
var result = [NSView]()
for subview in subviews {
if String(describing: type(of: subview)) == name {
result.append(subview)
}
result += subview.descendants(withClassName: name)
}
return result
}
}