TDKCandidates // Make CandidatePool into an ObservableObject.
This commit is contained in:
parent
6ed08e5355
commit
fe78a5c292
|
@ -142,6 +142,14 @@ public extension CandidatePool {
|
||||||
case vertical
|
case vertical
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func update() {
|
||||||
|
if #available(macOS 10.15, *) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.objectWillChange.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 往指定的方向翻頁。
|
/// 往指定的方向翻頁。
|
||||||
/// - Parameter isBackward: 是否逆向翻頁。
|
/// - Parameter isBackward: 是否逆向翻頁。
|
||||||
/// - Returns: 操作是否順利。
|
/// - Returns: 操作是否順利。
|
||||||
|
@ -418,3 +426,8 @@ private extension CandidatePool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Turn CandidatePool into an ObservableObject.
|
||||||
|
|
||||||
|
@available(macOS 10.15, *)
|
||||||
|
extension CandidatePool: ObservableObject {}
|
||||||
|
|
|
@ -117,6 +117,7 @@ public class CtlCandidateTDK: CtlCandidate, NSWindowDelegate {
|
||||||
Self.currentView = theViewCocoa
|
Self.currentView = theViewCocoa
|
||||||
break viewCheck
|
break viewCheck
|
||||||
}
|
}
|
||||||
|
Self.thePool.update()
|
||||||
Self.currentView = NSHostingView(rootView: theView)
|
Self.currentView = NSHostingView(rootView: theView)
|
||||||
} else {
|
} else {
|
||||||
Self.currentView = theViewCocoa
|
Self.currentView = theViewCocoa
|
||||||
|
|
|
@ -17,7 +17,7 @@ import SwiftUIBackports
|
||||||
public struct VwrCandidateTDK: View {
|
public struct VwrCandidateTDK: View {
|
||||||
public weak var controller: CtlCandidateTDK?
|
public weak var controller: CtlCandidateTDK?
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
@State public var thePool: CandidatePool
|
@Backport.StateObject public var thePool: CandidatePool
|
||||||
@State public var forceCatalinaCompatibility: Bool = false
|
@State public var forceCatalinaCompatibility: Bool = false
|
||||||
var tooltip: String { thePool.tooltip }
|
var tooltip: String { thePool.tooltip }
|
||||||
var reverseLookupResult: [String] { thePool.reverseLookupResult }
|
var reverseLookupResult: [String] { thePool.reverseLookupResult }
|
||||||
|
|
Loading…
Reference in New Issue