PrefUI // Add alternative tooltip button.

This commit is contained in:
ShikiSuen 2023-01-07 20:53:30 +08:00
parent 5fc601c692
commit 70c2eb954c
7 changed files with 21 additions and 3 deletions

View File

@ -6,6 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice // marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License. // requirements defined in MIT License.
import Cocoa
import Combine import Combine
import Foundation import Foundation
import LangModelAssembly import LangModelAssembly
@ -44,6 +45,7 @@ public struct VwrPhraseEditorUI: View {
@State public var selUserDataType: vChewingLM.ReplacableUserDataType = .thePhrases @State public var selUserDataType: vChewingLM.ReplacableUserDataType = .thePhrases
@State private var isLoading = false @State private var isLoading = false
@State private var textEditorTooltip = PETerms.TooltipTexts.sampleDictionaryContent(for: .thePhrases) @State private var textEditorTooltip = PETerms.TooltipTexts.sampleDictionaryContent(for: .thePhrases)
public weak var window: NSWindow?
public var currentIMEInputMode: Shared.InputMode { public var currentIMEInputMode: Shared.InputMode {
delegate?.currentInputMode ?? selInputMode delegate?.currentInputMode ?? selInputMode
@ -59,7 +61,7 @@ public struct VwrPhraseEditorUI: View {
// MARK: - // MARK: -
public init(delegate theDelegate: PhraseEditorDelegate? = nil) { public init(delegate theDelegate: PhraseEditorDelegate? = nil, window: NSWindow? = nil) {
_txtContent = .init( _txtContent = .init(
get: { Self.txtContentStorage }, get: { Self.txtContentStorage },
set: { newValue, _ in set: { newValue, _ in
@ -68,7 +70,10 @@ public struct VwrPhraseEditorUI: View {
} }
) )
guard let theDelegate = theDelegate else { return } guard let theDelegate = theDelegate else { return }
defer { delegate = theDelegate } defer {
delegate = theDelegate
self.window = window
}
} }
public func update() { public func update() {
@ -273,6 +278,13 @@ public struct VwrPhraseEditorUI: View {
} }
).help(PETerms.TooltipTexts.weightInputBox.localized) ).help(PETerms.TooltipTexts.weightInputBox.localized)
} }
Button("?") {
guard let window = window else { return }
window.callAlert(
title: "You may follow:".localized,
text: PETerms.TooltipTexts.sampleDictionaryContent(for: selUserDataType)
)
}.disabled(window == nil)
Button(PETerms.AddPhrases.locAdd.localized.0) { Button(PETerms.AddPhrases.locAdd.localized.0) {
DispatchQueue.main.async { insertEntry() } DispatchQueue.main.async { insertEntry() }
}.disabled(txtAddPhraseField1.isEmpty || txtAddPhraseField2.isEmpty) }.disabled(txtAddPhraseField1.isEmpty || txtAddPhraseField2.isEmpty)

View File

@ -38,7 +38,8 @@ struct VwrPrefPanePhrases: View {
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack { VStack {
VwrPhraseEditorUI(delegate: LMMgr.shared).frame(width: contentWidth + 28, height: 395) VwrPhraseEditorUI(delegate: LMMgr.shared, window: CtlPrefUI.shared.controller.window)
.frame(width: contentWidth + 28, height: 395)
Spacer() Spacer()
} }
.padding() .padding()

View File

@ -1,4 +1,5 @@
"vChewing" = "vChewing"; "vChewing" = "vChewing";
"You may follow:" = "You may follow:";
"Initial" = "Initial"; "Initial" = "Initial";
"Phrase" = "Phrase"; "Phrase" = "Phrase";
"Reading/Stroke" = "Reading/Stroke"; "Reading/Stroke" = "Reading/Stroke";

View File

@ -1,4 +1,5 @@
"vChewing" = "vChewing"; "vChewing" = "vChewing";
"You may follow:" = "You may follow:";
"Initial" = "Initial"; "Initial" = "Initial";
"Phrase" = "Phrase"; "Phrase" = "Phrase";
"Reading/Stroke" = "Reading/Stroke"; "Reading/Stroke" = "Reading/Stroke";

View File

@ -1,4 +1,5 @@
"vChewing" = "威注音入力アプリ"; "vChewing" = "威注音入力アプリ";
"You may follow:" = "このように:";
"Initial" = "頭文字"; "Initial" = "頭文字";
"Phrase" = "語彙"; "Phrase" = "語彙";
"Reading/Stroke" = "音読/筆画"; "Reading/Stroke" = "音読/筆画";

View File

@ -1,4 +1,5 @@
"vChewing" = "威注音输入法"; "vChewing" = "威注音输入法";
"You may follow:" = "你可以照这样:";
"Initial" = "首字"; "Initial" = "首字";
"Phrase" = "词语"; "Phrase" = "词语";
"Reading/Stroke" = "读音/字根"; "Reading/Stroke" = "读音/字根";

View File

@ -1,4 +1,5 @@
"vChewing" = "威注音輸入法"; "vChewing" = "威注音輸入法";
"You may follow:" = "你可以照這樣:";
"Initial" = "首字"; "Initial" = "首字";
"Phrase" = "詞語"; "Phrase" = "詞語";
"Reading/Stroke" = "讀音/字根"; "Reading/Stroke" = "讀音/字根";