-
Notifications
You must be signed in to change notification settings - Fork 104
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
NSBrowser bindings changes and general binding improvements #284
base: master
Are you sure you want to change the base?
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. |
Source/NSBrowser.m
Outdated
// but if one isn't it uses the description... per documentation. | ||
if (keyPath != nil) | ||
{ | ||
val = [child valueForKeyPath: keyPath]; |
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.
@fredkiefer Per our discussion yesterday I am going to try a few things to get the value directly with bindings. It seems to me that arrangedObjects.value would work if the data structure was a simple array, but given that it is a set of tree nodes with embedded children it doesn't seem quite as straightforward. It is still, perhaps, that I am not seeing something that is obvious.
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.
@fredkiefer Honestly, I have been thinking about this a lot. I don't know if there is a way to simplify it. With the path that is given arrangedObjects.value, this syntax is okay for arrays and simple data structures, but I am not sure it's going to work as we are using NSTreeNode or similar data structures. I agree that bindings should make things easier but I am not sure how to make it easier for US. sigh. As implemented this works as expected, but it uses the same "trick" to get the value as NSOutlineView. Alternatively, I would need to concatenate the value keyPath with arrangedObjects to get the above or, alternatively, get if it's a leaf or other attributes by doing something similar (manipulating the keyPath).
So it seems no matter what I do the solution is slightly messy. I apologize, a lot of this is me ranting after sitting here cogitating this for hours on end.
… 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.
@@ -3319,7 +3344,20 @@ - (id) _itemForColumn: (NSInteger)column | |||
{ | |||
id cell = [selectedCells objectAtIndex: 0]; | |||
|
|||
item = [cell objectValue]; | |||
if (theBinding != nil) |
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.
The binding is used only as an indicator. That way we could as well set the objectValue of each cell instead of storing the values in the _columnDictionary. This looks like we added complexity without gaining anything.
I would expect that if we want to treat bindings differently, we would try to get the values only when needed.
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.
I am working on this issue.
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.
I believe the better solution here might be to use the column matrix, but I am not certain. This would eliminate the need for the columnDictionary (possibly) the issue is that the binding based code generally needs the objects to be "nodes" which contain references to children, etc... the objectValue is used as what is displayed, so setting that the node class wouldn't work right. I am working through this.
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.
I have tried the above. It seems as though the objectValue needs to be the string or object actually being displayed, not the node.
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.
I don't know what you tried and why that failed. Those this mean that in the binding case it is not possible to set the value of the cells, while it works in the other cases? That really sounds weird. I really don't want to block you with this but the current code in this PR seems to have a lot of unnecessary complexity. If that gets into the codebase it is really hard to remove it again. I wouldn't be willing to pay that price but if you want to go ahead with it.
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.
The cell of the NSBrowser uses the objectValue as what is displayed in the browser. What I had tried was to set the objectValue to the actual node. This results in getting the columns correctly, but the data doesn't display properly. What I will do is try this another way to see if I can factor out the need for the columnDictionary.
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 |
This branch is to implement bindings in NSBrowser to NSTreeController and to fix and improve our use of bindings.