Skip to content

Commit 6da7c24

Browse files
committed
improve tooltip
1 parent eb57434 commit 6da7c24

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed
-32 Bytes
Binary file not shown.
-32 Bytes
Binary file not shown.

src/config/BasicConfig.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ struct BasicConfigView: View {
1919
let option = child["Option"] as? String ?? ""
2020
let description = child["Description"] as? String ?? ""
2121
let type = child["Type"] as? String ?? ""
22+
let isGroup = toOptionViewType(child) == GroupView.self
2223
let label =
2324
type == "External"
2425
? Text(description) as any View
25-
: Text(description).contextMenu {
26-
Button {
27-
onUpdate(mergeChild(value, option, extractValue(child, reset: true)))
28-
} label: {
29-
Text("Reset to default")
26+
: Text(description)
27+
.help(
28+
isGroup
29+
? NSLocalizedString("Right click to reset this group", comment: "")
30+
: NSLocalizedString("Right click to reset this item", comment: "")
31+
).contextMenu {
32+
Button {
33+
onUpdate(mergeChild(value, option, extractValue(child, reset: true)))
34+
} label: {
35+
Text("Reset to default")
36+
}
3037
}
31-
}
3238
let view = optionView(
3339
data: child,
3440
value: Binding(
@@ -37,11 +43,10 @@ struct BasicConfigView: View {
3743
onUpdate(mergeChild(value, option, $0))
3844
})
3945
)
40-
if toOptionViewType(child) == GroupView.self {
46+
if isGroup {
4147
// For group, put it inside a box and let it span two columns.
4248
VStack(alignment: .leading, spacing: 4) {
4349
AnyView(label).font(.title3)
44-
.help(NSLocalizedString("Right click to reset this group", comment: ""))
4550
view
4651
}
4752
} else {
@@ -51,7 +56,6 @@ struct BasicConfigView: View {
5156
// Hack: Punctuation map looks better without label.
5257
if type != "List|Entries$PunctuationMapEntryConfig" {
5358
AnyView(label).frame(width: 200, alignment: .trailing)
54-
.help(NSLocalizedString("Right click to reset this item", comment: ""))
5559
}
5660
view.frame(maxWidth: .infinity, alignment: .leading)
5761
}

src/config/FooterView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ struct FooterView: View {
2121
Button {
2222
manager.reset()
2323
} label: {
24-
Text("Reset to default")
24+
Text("Reset to default").tooltip(
25+
NSLocalizedString(
26+
"Reset current page. To reset a single item/group, right click on its label.",
27+
comment: ""
28+
))
2529
}
2630

2731
Spacer()

src/config/ui.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extension View {
1515
func tooltip(_ text: String) -> some View {
1616
HStack {
1717
self
18-
Image(systemName: "questionmark.circle.fill").help(text)
19-
}
18+
Image(systemName: "questionmark.circle.fill")
19+
}.help(text)
2020
}
2121

2222
// Enlarge clickable area for border-less icon button, especially minus.

0 commit comments

Comments
 (0)