Zonble: Reload cand. data when CandidateControllerDelegate did set

This commit is contained in:
ShikiSuen 2022-01-19 00:40:54 +08:00
parent f13af39bd3
commit 5837b8e768
1 changed files with 15 additions and 1 deletions

View File

@ -17,7 +17,11 @@ public protocol CandidateControllerDelegate: AnyObject {
@objc(VTCandidateController) @objc(VTCandidateController)
public class CandidateController: NSWindowController { public class CandidateController: NSWindowController {
@objc public weak var delegate: CandidateControllerDelegate? @objc public weak var delegate: CandidateControllerDelegate? {
didSet {
reloadData()
}
}
@objc public var selectedCandidateIndex: UInt = UInt.max @objc public var selectedCandidateIndex: UInt = UInt.max
@objc public var visible: Bool = false { @objc public var visible: Bool = false {
didSet { didSet {
@ -69,6 +73,16 @@ public class CandidateController: NSWindowController {
UInt.max UInt.max
} }
/// Sets the location of the candidate window.
///
/// Please note that the method has side effects that modifies
/// `windowTopLeftPoint` to make the candidate window to stay in at least
/// in a screen.
///
/// - Parameters:
/// - windowTopLeftPoint: The given location.
/// - height: The height that helps the window not to be out of the bottom
/// of a screen.
@objc(setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:) @objc(setWindowTopLeftPoint:bottomOutOfScreenAdjustmentHeight:)
public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) { public func set(windowTopLeftPoint: NSPoint, bottomOutOfScreenAdjustmentHeight height: CGFloat) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {