Re: Alternatives to NSMatrix that uses bindings similar to NSMatrix's bindings
Re: Alternatives to NSMatrix that uses bindings similar to NSMatrix's bindings
- Subject: Re: Alternatives to NSMatrix that uses bindings similar to NSMatrix's bindings
- From: Nivek Research <email@hidden>
- Date: Fri, 08 Apr 2016 08:05:53 -0400
Hi Graham,
I believe the part you are missing is the ability to use bindings and ideally bindings setup in IB. The bulk of Sean McBride’s code simulates the binding behavior of NSMatrix (i.e., keeping a model property in sync with the visual display and vice versa) and his code does this only for selectedTag. While your awakeFromNib implementation may be more generic then Sean’s the end result from what I see is that the model still needs to have a reference to the view to set the selectedIndex property. Otherwise something similar to Sean’s code is needed to establish a binding between the custom view’s selectedTag/selectedIndex and a model property. To my knowledge Apple has not provided a means to setup value bindings for custom views in IB.
Ultimately, I am quite aware that I will need to write code to solve the problem. However, I am looking for a solution that requires no modification to the model and especially no understanding of a custom view and its properties. Ideally I would also like one that can mostly be configured from IB as one would do today with NSMatrix.
—kevin
> On Apr 8, 2016, at 7:49 AM, Graham Cox <email@hidden> wrote:
>
>
>> On 8 Apr 2016, at 8:44 PM, Graham Cox <email@hidden> wrote:
>>
>> Off the top of my head I can imagine how this code would look and with due respect to Sean, it would be a lot less complicated than RRRadioBinder.
>
> OK, here’s what I had in mind. Super simple, tested and works, though I ran into one small difficulty - it’s hard to tell given an NSButton instance whether it’s a radio button. There’s no -buttonType property and the bezel type returned isn’t the ‘circular’ style as you might expect so I’m not sure what unique set of properties imply a radio. For now, I just assume that ALL NSButton subviews of the group are radio buttons, which is not unreasonable. Also, for 10.8+, the button highlighting will be done twice - once by this code and once by NSView’s default implementation. It’s harmless, the user doesn’t see it, and the -selectedIndex property is only changed once, but if it bothers you you could add in some conditionals based on OS version.
>
> —Graham
>
> <GCRadioGroupView.h><GCRadioGroupView.m>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden