File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,19 @@ import Cocoa
99
1010// https://stackoverflow.com/a/54310657/1439489
1111extension NSView {
12- func bringSubviewToFront( _ view: NSView ) {
13- var theView = view
14- self . sortSubviews ( { ( viewA, viewB, rawPointer) in
15- let view = rawPointer? . load ( as: NSView . self)
16-
17- switch view {
18- case viewA:
12+ func bringSubviewToFront( _ subview: NSView ) {
13+ self . sortSubviews ( { ( viewA, viewB, subviewID) in
14+ if viewA. uniqueID == subviewID {
1915 return ComparisonResult . orderedDescending
20- case viewB:
16+ }
17+ if viewB. uniqueID == subviewID {
2118 return ComparisonResult . orderedAscending
22- default :
23- return ComparisonResult . orderedSame
2419 }
25- } , context: & theView)
20+ return ComparisonResult . orderedSame
21+ } , context: subview. uniqueID)
22+ }
23+
24+ private var uniqueID : UnsafeMutableRawPointer {
25+ return Unmanaged . passUnretained ( self ) . toOpaque ( )
2626 }
2727}
You can’t perform that action at this time.
0 commit comments