-
Notifications
You must be signed in to change notification settings - Fork 107
NSBrowser bindings changes and general binding improvements #284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@fredkiefer Converted to draft. Sorry. :) |
83958c1
to
35fb894
Compare
It's now working, I am reviewing how it's working because I had to do something similar to what I did in NSOutlineView, which I am not sure of. |
… and valueForKey:
@fredkiefer These changes currently function as intended. I am still looking for a way to simplify them to your satisfaction. I am unconvinced, however, that, given the complexity of the data structure, that KVB can do it as simply as we would like. Ultimately, I'm wondering if it even matters if it is simple on our side as long as it works and is simple for the developer/user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I might be wrong with some of the comments, it is just I don't understand the intention behind all this.
No worries. I'll do my best to explain the intentions behind each change. There were honestly some things in the macOS implementation that I didn't understand myself. |
With your permission, I will go ahead and merge this unless you have any overriding concerns. @fredkiefer |
@fredkiefer I have made further changes to the tests that indicate that the objectValue is set to the string of the node on Cocoa. I feel as though I have explored every possibility. The only solution is to maintain some parallel data structure. If I could store it in the cell itself, that would be feasible. |
Let's go back a step and look at all this from the outside. An NSBrowser has different ways to get its values for display. This could be via different types of delegates, that come either as item based delegate, passive delegate or a delegate that creates the rows for each column itself. Could you please point me to the test code that you are using for this feature? Maybe I will be able to better understand what you are trying to handle with your changes. |
@fredkiefer its here: https://github.com/gcasa/NSBrowser_binding_test I though I had linked this before. My convention is to name the test similar to the branch name so I can keep it straight. My apologies. |
I will make further comments in the morning. I am not feeling well at the moment. I will explain why it contains and uses NSContentBinding and NSValueBinding the way it does. |
The code as I have implemented it does this. It gets the relevant data from the bindings rather than from the delegate.
The bindings behave very much like the item based delegate in how the data is pulled from each node.
Is that not what is being done? Every method that pulls the data has different conditionals for when a delegate is used and when a binding is used.
This difference is called for in the documentation... See under content... it says that "Unless contentValues is also bound, the titles of the items in the NSBrowser are derived by invoking invoking the descriptionmethod for each of the content objects."
See above.
Previous comment does this. https://github.com/gcasa/NSBrowser_binding_test Per the test, the behavior as I have implemented it is consistent with the documentation and tests on macOS Ventura. Please let me know if you can think of a cleaner way to implement this as I am at a loss. |
I updated the test mentioned in the earlier comment to have a delegate. The result on macOS is this...
The result on GNUstep is that the delegate is simply ignored if the binding is present. I believe this behavior can be deemed as undefined since this is not covered in the documentation. |
We get the following on the dual_controller branch which tests the idea that we can support different controllers for content and contentValues bindings. This doesn't appear to work, per the following...
Please let me know if you have any other concerns. The GNUstep code in this case seems to recurse or loop, but as this is an undefined case I believe that doesn't matter. |
I believe that all issues with this change have been adequately addressed. The above tests address the issue where we have a delegate in addition to the binding (a case that crashes macOS) and the case where we have separate bindings for NSObjectValue and NSContentValue (a case that also crashes macOS). GNUstep handles them both. Also, the tests match the functionality as expected on macOS. Please make any final comments. |
@fredkiefer Please review. :) |
Hi Greg, Judging from the stack traces from MacOS you provided above, Apple went a completely different way to implement this. They seem to have introduced an adopter that maps the binding behaviour onto a delegate. When done properly this could be a very clean solution. |
I agree that it can be done better and I made the same observation with respect to the adapter as I have seen it before in back traces but I have no idea how it functions. For now I will merge this. I will revisit it and the outline code when I have a better idea about the bindings adapter. Thanks for all of your help and feedback. |
This branch is to implement bindings in NSBrowser to NSTreeController and to fix and improve our use of bindings.