Skip to content

Commit

Permalink
PhraseEditor // Release some memory when it gets disappeared.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Dec 20, 2022
1 parent ac6b53b commit d2107f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public struct VwrPhraseEditorUI: View {
selInputMode = .imeModeNULL
selUserDataType = .thePhrases
txtContent = NSLocalizedString("Please select Simplified / Traditional Chinese mode above.", comment: "")
isLoading = true
Self.txtContentStorage = ""
}.onAppear {
guard let delegate = delegate else { return }
selInputMode = delegate.currentInputMode
Expand Down
9 changes: 7 additions & 2 deletions Source/Modules/WindowControllers/CtlPrefWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension NSToolbarItem.Identifier {
// 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
// of this build target.
class CtlPrefWindow: NSWindowController {
class CtlPrefWindow: NSWindowController, NSWindowDelegate {
@IBOutlet var fontSizePopUpButton: NSPopUpButton!
@IBOutlet var uiLanguageButton: NSPopUpButton!
@IBOutlet var basicKeyboardLayoutButton: NSPopUpButton!
Expand Down Expand Up @@ -66,8 +66,9 @@ class CtlPrefWindow: NSWindowController {
public static var shared: CtlPrefWindow?

static func show() {
if shared == nil { shared = CtlPrefWindow(windowNibName: "frmPrefWindow") }
shared = CtlPrefWindow(windowNibName: "frmPrefWindow")
guard let sharedWindow = shared?.window else { return }
sharedWindow.delegate = shared
sharedWindow.center()
sharedWindow.orderFrontRegardless() // 逼著視窗往最前方顯示
sharedWindow.level = .statusBar
Expand Down Expand Up @@ -174,6 +175,10 @@ class CtlPrefWindow: NSWindowController {
initPhraseEditor()
}

func windowWillClose(_: Notification) {
tfdPETextEditor.string = ""
}

// 這裡有必要加上這段處理,用來確保藉由偏好設定介面動過的 CNS 開關能夠立刻生效。
// 所有涉及到語言模型開關的內容均需要這樣處理。
@IBAction func toggleCNSSupport(_: Any) {
Expand Down

0 comments on commit d2107f8

Please sign in to comment.