Disable remove button in replacement set panel when nothing is selected

This commit is contained in:
1024jp 2018-04-11 17:53:33 +09:00
parent d9e3431864
commit dafa1d07cb
2 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,7 @@ unreleased
- [beta] Synchronize the selection in the outline inspector with the current cursor position in the focused editor.
- [beta] Replace with new one when the last replacement definition row was removed, instead of desabling the remove button.
- [beta] Disable the remove button in replacement set panel when nothing is selected.

View File

@ -43,7 +43,7 @@ final class ReplacementSetViewController: NSViewController, ReplacementSetPanelV
private var replacementSet = ReplacementSet()
private lazy var updateNotificationTask: Debouncer = Debouncer(delay: 1.0) { [weak self] in self?.notifyUpdate() }
@objc private dynamic var canRemove: Bool = true
@objc private dynamic var canRemove: Bool = false
@objc private dynamic var hasInvalidSetting = false
@objc private dynamic var resultMessage: String?
@ -237,6 +237,16 @@ private extension NSPasteboard.PasteboardType {
extension ReplacementSetViewController: NSTableViewDelegate {
/// selection did change
func tableViewSelectionDidChange(_ notification: Notification) {
guard let tableView = self.tableView else { return }
// update
self.canRemove = tableView.selectedRow >= 0
}
/// make table cell view
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {