Open
Conversation
In doing some of my own work, I found that I was duplicating a lot of what was already done in Rex, so I ported over much of what I've done on my own in order to better consolidate things. There isn't a complete 1:1 test matching at the moment with the new AppKit methods, and I "broke" the API for NSTextField that was already in place to better match with conventions used elsewhere in RAC, and to distinguish between continuous and "normal" control events.
Originally developed alongside a forthcoming update to FuzzMeasure (http://fuzzmeasure.com), this is my take on one way that Cocoa Bindings-like behavior may be approximated using RAC. In addition to the `Signal`s that contain controls' changing values, the `ConsumerBinding` provides the "other half" of the equation—updating their state to reflect incoming values. Like Cocoa Bindings, values are wrapped by placeholders that represent selection states such as `MultipleValues` and `NoSelection`. A new `PropertyBinding` is a similar concept that exists for model objects to expose, where a `validator` function is provided to allow the "massaging" of incoming values. This approximates the role of Key-Value Validation as it existed within Cocoa Bindings. This changeset does not include any examples, sadly. Hopefully I can put something together in the near future to share.
Trying to use Action-based triggers for values, in general, as NSControls have always worked on a target/action-based system.
The joy of importing code from an app into a framework is all the internal -> public promotion...
Member
|
I did a quick pass on this but having never used Cocoa Bindings (or any meaningful Mac development for that matter) it'll take me a bit longer to digest this and offer feedback. |
Author
|
@neilpa It's a lot to digest. I sort of "rushed" to dump this code (after carefully building it, and using it successfully) into the repo because I wanted to make it available for my other projects sooner. I'm hoping to come up with a small enough example to demonstrate this soon. |
# Conflicts: # .travis.yml # Cartfile # Cartfile.resolved # Rex.xcodeproj/project.pbxproj
Also made changes to port existing bindings code to Swift 3, to ensure it all still compiles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Originally developed alongside a forthcoming update to FuzzMeasure (http://fuzzmeasure.com), this is my take on one way that Cocoa Bindings-like behavior may be approximated using RAC.
In addition to the
Signals that contain controls' changing values, theConsumerBindingprovides the "other half" of the equation—updating their state to reflect incoming values. Like Cocoa Bindings, values are wrapped by placeholders that represent selection states such asMultipleValuesandNoSelection.A new
PropertyBindingis a similar concept that exists for model objects to expose, where avalidatorfunction is provided to allow the "massaging" of incoming values. This approximates the role of Key-Value Validation as it existed within Cocoa Bindings.This changeset does not include any examples, sadly. Hopefully I can put something together in the near future to share. Also, I need to adjust whitespace as this code was built alongside a project that uses 4 spaces in place of tabs. 😛
In addition to the above, this PR includes some additional extensions for AppKit controls.