Problems binding NSViewController's representedObject
Hi, I've posted here: http://stackoverflow.com/questions/22573176/why-is-nsviewcontroller-not-binding-representedobject There's code and screenshots in the above link, but the basics are this: I've created an `NSViewController` subclass, with a corresponding xib. I try to set a simple model object to the controller's `representedObject` property, and bind a text field to `representedObject.firstName`. It works to initially fill in the text field, but when I edit the text field, the model isn't updating. Any ideas? Rob zipped up demo project: https://drive.google.com/file/d/0B2NHW8y0ZrBwWjNzbGszaDQzQ1U/edit?usp=sharing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problems binding NSViewController's representedObject
There's an answer on stackoverflow. I wasn't keeping a strong reference to the ViewController. Doh. On Sat, Mar 22, 2014 at 8:54 AM, Rob Nikander rob.nikan...@gmail.comwrote: Hi, I've posted here: http://stackoverflow.com/questions/22573176/why-is-nsviewcontroller-not-binding-representedobject There's code and screenshots in the above link, but the basics are this: I've created an `NSViewController` subclass, with a corresponding xib. I try to set a simple model object to the controller's `representedObject` property, and bind a text field to `representedObject.firstName`. It works to initially fill in the text field, but when I edit the text field, the model isn't updating. Any ideas? Rob zipped up demo project: https://drive.google.com/file/d/0B2NHW8y0ZrBwWjNzbGszaDQzQ1U/edit?usp=sharing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
auto layout, 10.9, and NSScrollView and friends
Hi, Last year I did some work in Cocoa and discovered that the auto layout stuff was not completely supported in some common AppKit classes. I remember having problems with NSScrollView and NSOutlineView. This message talks in detail about some issues with NSScrollView... http://lists.apple.com/archives/cocoa-dev/2013/Mar/msg00274.html It ends with the sentence Let's see what 10.9 brings. So, I'm getting back into Cocoa, and my question is: what did 10.9 bring? I did some searching and don't see any encouraging release notes or announcements. Has anything changed with this issue? Constraint based layout seems really cool, but it's odd that it doesn't work with such important AppKit classes. If it's not working easily, do people get it to work with some extra effort, or should I just avoid NSScrollView and the others, if I use auto layout? thanks, Rob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to observe validity of NSTextField+NSNumberFormatter?
Hi, I want to constrain an NSTextField to float values greater than zero, so I connected an NSNumberFormatter in Interface Builder. Now the user can enter invalid text (eg, 1a, -2) but it beeps when you try to leave the field. That may be okay. Now I'd like to disable other parts of the UI when the field is invalid. I connected a delegate to the NSTextField, and implemented `controlTextDidChange:`, but I don't know how to check the validity from within that method. I get some strange behavior when I call textField.doubleValue, or even textField.stringValue, from inside controlTextDidChange. It causes the textfield to behave differently -- instead of allowing invalid text and beeping later, it erases the invalid text as soon as you type it. So first question: why is that happening? What is getting called by `textField.whateverValue` to change the field? Second question: how to I ask the NSNumberFormatter about the validity of the field as the field changes? I'd call its `getObjectValue...` method but I can seem to get the field's string value in `controlTextDidChange:`, without changing the behavior as described above. thanks, Rob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to observe validity of NSTextField+NSNumberFormatter?
Aha, I just read about the window's FieldEditor in the Cocoa Text Architecture Guide. That answers most of my question. I'm still wondering why calling textField.doubleValue during the notification changes the value of the field. But with the field editor I can check the validity as I wanted to. Rob On Fri, Aug 23, 2013 at 12:57 PM, Rob Nikander rob.nikan...@gmail.comwrote: Hi, I want to constrain an NSTextField to float values greater than zero, so I connected an NSNumberFormatter in Interface Builder. Now the user can enter invalid text (eg, 1a, -2) but it beeps when you try to leave the field. That may be okay. Now I'd like to disable other parts of the UI when the field is invalid. I connected a delegate to the NSTextField, and implemented `controlTextDidChange:`, but I don't know how to check the validity from within that method. I get some strange behavior when I call textField.doubleValue, or even textField.stringValue, from inside controlTextDidChange. It causes the textfield to behave differently -- instead of allowing invalid text and beeping later, it erases the invalid text as soon as you type it. So first question: why is that happening? What is getting called by `textField.whateverValue` to change the field? Second question: how to I ask the NSNumberFormatter about the validity of the field as the field changes? I'd call its `getObjectValue...` method but I can seem to get the field's string value in `controlTextDidChange:`, without changing the behavior as described above. thanks, Rob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why are these layout constraints being ignored?
Thanks, it's good to know I'm not the only one. I've abandoned constraints for now and am using the old way. Rob On Tue, Jul 2, 2013 at 12:43 PM, Kyle Sluder k...@ksluder.com wrote: On Jun 25, 2013, at 6:10 AM, Rob Nikander rob.nikan...@gmail.com wrote: I create 4 constraints with the desire to pin the NSOutlineView to the edges of it's superview (the NSWindow's contentView). It works, until I expand/collapse items in the outline view. Then the constraints are ignored and the outline shrinks. Why are they ignored? What is it in the outline view that is taking priority? It's intrinsicContentSize is (-1,-1) which I thought meant it could be stretched out to satisfy other constraints. Long story short, NSOutlineView (and NSTableView) will do one of two behaviors when tiling: 1. Inside an NSClipView (which is the case when it is the document view of an NSScrollView), it will fill its clip view or its content, whichever is bigger. 2. Outside of an NSClipView, it will resize to hug its content as small as possible. Obviously, neither of these is compatible with auto layout. There are no override hooks to customize this behavior. The only thing I have found that works reliably is to put the table view inside an NSClipView, and resize that appropriately. Please file radars on the inflexibility of NSTableView. I know I have. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Why are these layout constraints being ignored?
Hi, I don't think I can attach images here, so I'll link to a stackoverflow question with images of the layout. http://stackoverflow.com/questions/17288279/why-is-this-nsoutlineview-ignoring-layout-constraints I create 4 constraints with the desire to pin the NSOutlineView to the edges of it's superview (the NSWindow's contentView). It works, until I expand/collapse items in the outline view. Then the constraints are ignored and the outline shrinks. Why are they ignored? What is it in the outline view that is taking priority? It's intrinsicContentSize is (-1,-1) which I thought meant it could be stretched out to satisfy other constraints. I may be able to post code if that helps. thanks, Rob (I know that you usually put an NSOutlineView in a NSScrollView, but I've tried to simplify my example to focus on what I don't understand.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com