Skip to content

Enable view-based NSTableViews to reload entire rows#138

Merged
ra1028 merged 1 commit into
ra1028:masterfrom
ibsh:master
Mar 21, 2022
Merged

Enable view-based NSTableViews to reload entire rows#138
ra1028 merged 1 commit into
ra1028:masterfrom
ibsh:master

Conversation

@ibsh
Copy link
Copy Markdown
Contributor

@ibsh ibsh commented Jan 18, 2022

Checklist

Description

When an NSTableView has view-based cells (e.g. NSTableViewDelegate's tableView(_:viewFor:row:) is implemented, rather than just NSTableViewDataSource's tableView(_:objectValueFor:row)), its behaviour when reloadData(forRowIndexes:columnIndexes) is called changes.

When cell values are only derived from tableView(_:objectValueFor:row), a reload call with any set of columnIndexes will lead to the whole row being refreshed. When the delegate method above is implemented, only the columns of that row directly addressed by the columnIndexes argument are reloaded.

The current code in the AppKit extension always passes a columnIndexes argument of [0]1, which therefore only updates the 0th column's cell in any row to which the reload is applied.

My change explicitly adds all valid column indexes to the reloadData call, so that an entire row is refreshed when its associated data element is updated.

Related Issue

I can raise one with the above observations if it's deemed necessary.

Motivation and Context

I was motivated by the fact that my NSTableView wouldn't properly refresh. Apologies for not adding documentation or tests but this particular extension lacks these in the first place.

Impact on Existing Code

I can see no negative impact on existing code, and no risk to the core algorithm since my changes are limited to the AppKit extension.

Screenshots (if appropriate)

Footnotes

  1. or more accurately of the element's section value, which seems to be an oversight.

…t the first column in the row, when an element is updated.
@ra1028
Copy link
Copy Markdown
Owner

ra1028 commented Mar 21, 2022

Sorry for my late response.
I don't really familiar with macos app dev but your explanation makes sense to me.
Thanks!

@ra1028 ra1028 merged commit 8d45ea9 into ra1028:master Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants