Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Delete key now respects cell-range selection in the data grid, removing all rows covered by the selection instead of ignoring it.
- Right-clicking a row inside a multi-row selection no longer collapses the selection before the context menu appears.
- iCloud Sync between the iPhone and Mac apps: the iOS app now uses the Production CloudKit environment, so a development build no longer syncs into a separate database the Mac never reads.
- Exports no longer fail mid-table on servers that enforce a statement time limit; the export session disables the limit and restores it afterwards, the same way mysqldump does. (#1633)

Expand Down
24 changes: 22 additions & 2 deletions TablePro/Views/Results/KeyHandlingTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ final class KeyHandlingTableView: NSTableView {

@objc func delete(_ sender: Any?) {
guard coordinator?.isEditable == true else { return }
if let controller = gridSelection, !controller.isEmpty {
let rows = controller.selection.affectedRows
guard !rows.isEmpty else { return }
coordinator?.delegate?.dataGridDeleteRows(Set(rows))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear the cell-range selection after deleting inserted rows

When the selected range includes newly inserted rows, dataGridDeleteRows(Set(rows)) physically removes those rows, but the grid selection is left intact: applyRemovedRows only updates/removes table rows and syncSelection performs the next row selection programmatically, so tableViewSelectionDidChange does not clear selectionController. After deleting a cell range over inserted rows, the Delete menu remains enabled from the stale grid selection and pressing Delete again deletes whatever rows shifted into the old indexes.

Useful? React with 👍 / 👎.

return
}
guard !selectedRowIndexes.isEmpty else { return }
coordinator?.delegate?.dataGridDeleteRows(Set(selectedRowIndexes))
}
Expand Down Expand Up @@ -279,7 +285,8 @@ final class KeyHandlingTableView: NSTableView {
override func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
switch item.action {
case #selector(delete(_:)), #selector(deleteBackward(_:)):
return coordinator?.isEditable == true && !selectedRowIndexes.isEmpty
let hasGridSelection = gridSelection?.isEmpty == false
return coordinator?.isEditable == true && (hasGridSelection || !selectedRowIndexes.isEmpty)
case #selector(copy(_:)):
let hasGridSelection = gridSelection?.isEmpty == false
return hasGridSelection || !selectedRowIndexes.isEmpty
Expand Down Expand Up @@ -407,7 +414,7 @@ final class KeyHandlingTableView: NSTableView {

private func deleteSelectedRowsIfPossible() {
guard coordinator?.isEditable == true else { return }
guard !selectedRowIndexes.isEmpty else { return }
guard gridSelection?.isEmpty == false || !selectedRowIndexes.isEmpty else { return }
delete(nil)
}

Expand Down Expand Up @@ -521,6 +528,19 @@ final class KeyHandlingTableView: NSTableView {
scrollColumnToVisible(prevColumn)
}

override func rightMouseDown(with event: NSEvent) {
let point = convert(event.locationInWindow, from: nil)
let clickedRow = row(at: point)
if clickedRow >= 0, selectedRowIndexes.contains(clickedRow) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve right-clicks inside cell-range selections

This fast path only recognizes rows in selectedRowIndexes, but a grid cell-range selection can span many rows while the NSTableView row selection contains only the focused row. Right-clicking a selected cell on another row falls through to super.rightMouseDown, which selects the clicked row; tableViewSelectionDidChange then clears selectionController when the change is not programmatic, so the context menu still appears after collapsing the cell-range selection. The condition needs to also treat clicks inside gridSelection.selection as selected.

Useful? React with 👍 / 👎.

window?.makeFirstResponder(self)
if let menu = menu(for: event) {
NSMenu.popUpContextMenu(menu, with: event, for: self)
}
return
}
super.rightMouseDown(with: event)
}

override func menu(for event: NSEvent) -> NSMenu? {
let point = convert(event.locationInWindow, from: nil)
let clickedRow = row(at: point)
Expand Down
Loading