PhraseEditor // Release some memory when it gets disappeared.

This commit is contained in:
ShikiSuen 2022-12-09 22:16:41 +08:00
parent ac6b53b3ec
commit d2107f847a
2 changed files with 9 additions and 2 deletions

View File

@ -297,6 +297,8 @@ public struct VwrPhraseEditorUI: View {
selInputMode = .imeModeNULL selInputMode = .imeModeNULL
selUserDataType = .thePhrases selUserDataType = .thePhrases
txtContent = NSLocalizedString("Please select Simplified / Traditional Chinese mode above.", comment: "") txtContent = NSLocalizedString("Please select Simplified / Traditional Chinese mode above.", comment: "")
isLoading = true
Self.txtContentStorage = ""
}.onAppear { }.onAppear {
guard let delegate = delegate else { return } guard let delegate = delegate else { return }
selInputMode = delegate.currentInputMode selInputMode = delegate.currentInputMode

View File

@ -28,7 +28,7 @@ extension NSToolbarItem.Identifier {
// only works with macOS System Preference pane (like macOS built-in input methods). // only works with macOS System Preference pane (like macOS built-in input methods).
// It should be set as "Preferences" which correspondes to the "Preference" pref pane // It should be set as "Preferences" which correspondes to the "Preference" pref pane
// of this build target. // of this build target.
class CtlPrefWindow: NSWindowController { class CtlPrefWindow: NSWindowController, NSWindowDelegate {
@IBOutlet var fontSizePopUpButton: NSPopUpButton! @IBOutlet var fontSizePopUpButton: NSPopUpButton!
@IBOutlet var uiLanguageButton: NSPopUpButton! @IBOutlet var uiLanguageButton: NSPopUpButton!
@IBOutlet var basicKeyboardLayoutButton: NSPopUpButton! @IBOutlet var basicKeyboardLayoutButton: NSPopUpButton!
@ -66,8 +66,9 @@ class CtlPrefWindow: NSWindowController {
public static var shared: CtlPrefWindow? public static var shared: CtlPrefWindow?
static func show() { static func show() {
if shared == nil { shared = CtlPrefWindow(windowNibName: "frmPrefWindow") } shared = CtlPrefWindow(windowNibName: "frmPrefWindow")
guard let sharedWindow = shared?.window else { return } guard let sharedWindow = shared?.window else { return }
sharedWindow.delegate = shared
sharedWindow.center() sharedWindow.center()
sharedWindow.orderFrontRegardless() // sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar sharedWindow.level = .statusBar
@ -174,6 +175,10 @@ class CtlPrefWindow: NSWindowController {
initPhraseEditor() initPhraseEditor()
} }
func windowWillClose(_: Notification) {
tfdPETextEditor.string = ""
}
// CNS // CNS
// //
@IBAction func toggleCNSSupport(_: Any) { @IBAction func toggleCNSSupport(_: Any) {