TDKCandidates // Add context menu support.
This commit is contained in:
parent
1d593b490f
commit
5db19f854e
|
@ -51,6 +51,12 @@ public struct VwrCandidateHorizontal: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) {
|
||||
if let delegate = controller?.delegate {
|
||||
delegate.candidatePairRightClicked(at: pos, action: action)
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
|
@ -65,6 +71,25 @@ public struct VwrCandidateHorizontal: View {
|
|||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toBoost)
|
||||
} label: {
|
||||
Text("↑ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toNerf)
|
||||
} label: {
|
||||
Text("↓ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toFilter)
|
||||
} label: {
|
||||
Text("✖︎ " + currentCandidate.displayedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}.frame(
|
||||
|
|
|
@ -50,6 +50,12 @@ public struct VwrCandidateVertical: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) {
|
||||
if let delegate = controller?.delegate {
|
||||
delegate.candidatePairRightClicked(at: pos, action: action)
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
|
@ -65,6 +71,25 @@ public struct VwrCandidateVertical: View {
|
|||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toBoost)
|
||||
} label: {
|
||||
Text("↑ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toNerf)
|
||||
} label: {
|
||||
Text("↓ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toFilter)
|
||||
} label: {
|
||||
Text("✖︎ " + currentCandidate.displayedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.frame(
|
||||
|
|
|
@ -52,6 +52,12 @@ public struct VwrCandidateHorizontalBackports: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) {
|
||||
if let delegate = controller?.delegate {
|
||||
delegate.candidatePairRightClicked(at: pos, action: action)
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
|
@ -66,6 +72,25 @@ public struct VwrCandidateHorizontalBackports: View {
|
|||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toBoost)
|
||||
} label: {
|
||||
Text("↑ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toNerf)
|
||||
} label: {
|
||||
Text("↓ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toFilter)
|
||||
} label: {
|
||||
Text("✖︎ " + currentCandidate.displayedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}.frame(
|
||||
|
|
|
@ -51,6 +51,12 @@ public struct VwrCandidateVerticalBackports: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func didRightClickCandidateAt(_ pos: Int, action: CandidateContextMenuAction) {
|
||||
if let delegate = controller?.delegate {
|
||||
delegate.candidatePairRightClicked(at: pos, action: action)
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
|
@ -66,6 +72,25 @@ public struct VwrCandidateVerticalBackports: View {
|
|||
)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toBoost)
|
||||
} label: {
|
||||
Text("↑ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toNerf)
|
||||
} label: {
|
||||
Text("↓ " + currentCandidate.displayedText)
|
||||
}
|
||||
Button {
|
||||
didRightClickCandidateAt(currentCandidate.index, action: .toFilter)
|
||||
} label: {
|
||||
Text("✖︎ " + currentCandidate.displayedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.frame(
|
||||
|
|
Loading…
Reference in New Issue