TDKCandidates // Disallow filtering single kanjis through context menu.

This commit is contained in:
ShikiSuen 2023-03-07 12:02:01 +08:00
parent a846fe48ac
commit 837bce78cf
2 changed files with 23 additions and 15 deletions

View File

@ -339,25 +339,29 @@ private extension VwrCandidateTDKCocoa {
action: #selector(menuActionOfBoosting(_:)), action: #selector(menuActionOfBoosting(_:)),
keyEquivalent: "" keyEquivalent: ""
) )
boostMenuItem.target = self
newMenu.addItem(boostMenuItem)
let nerfMenuItem = NSMenuItem( let nerfMenuItem = NSMenuItem(
title: "\(cellData.displayedText)", title: "\(cellData.displayedText)",
action: #selector(menuActionOfNerfing(_:)), action: #selector(menuActionOfNerfing(_:)),
keyEquivalent: "" keyEquivalent: ""
) )
nerfMenuItem.target = self
newMenu.addItem(nerfMenuItem)
if let dataAll = (target as? VwrCandidateTDKCocoa)?.thePool.candidateDataAll,
dataAll.count > cellData.index, dataAll[cellData.index].spanLength > 1
{
let filterMenuItem = NSMenuItem( let filterMenuItem = NSMenuItem(
title: "✖︎ \(cellData.displayedText)", title: "✖︎ \(cellData.displayedText)",
action: #selector(menuActionOfFiltering(_:)), action: #selector(menuActionOfFiltering(_:)),
keyEquivalent: "" keyEquivalent: ""
) )
boostMenuItem.target = self
nerfMenuItem.target = self
filterMenuItem.target = self filterMenuItem.target = self
newMenu.addItem(boostMenuItem)
newMenu.addItem(nerfMenuItem)
newMenu.addItem(filterMenuItem) newMenu.addItem(filterMenuItem)
}
theMenu = newMenu theMenu = newMenu
} }

View File

@ -168,6 +168,9 @@ extension VwrCandidateTDK {
} label: { } label: {
Text("" + cell.displayedText) Text("" + cell.displayedText)
} }
if thePool.candidateDataAll.count > cell.index,
thePool.candidateDataAll[cell.index].spanLength > 1
{
Button { Button {
didRightClickCandidateAt(cell.index, action: .toFilter) didRightClickCandidateAt(cell.index, action: .toFilter)
} label: { } label: {
@ -176,6 +179,7 @@ extension VwrCandidateTDK {
} }
} }
} }
}
func lineBackground(lineID: Int) -> Color { func lineBackground(lineID: Int) -> Color {
let isCurrentLineInMatrix = lineID == thePool.currentLineNumber && thePool.maxLinesPerPage != 1 let isCurrentLineInMatrix = lineID == thePool.currentLineNumber && thePool.maxLinesPerPage != 1