Resize Superviews
I put an important question in a post with too much other information, so I’m not surprised nobody answered it. I need a text editor control that will size itself vertically to contain text as the user types or pastes it in. That means: The text container must size itself vertically to fit the text The text view must size itself vertically to fit the text container The text view must somehow notify its superview that its size has changed. Does anyone know how to do this? What I’ve tried so far is setting the text container’s widthTracksView to YES and pinning the text view to the size of its scroll view, so the widths are handled, I think. But I don’t know where to begin to get the height to resize from the inside out. Thank you! — Charles Jenkins ___ 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: Resize Superviews
Well naturally, two minutes after posting this question, I finally found Apple’s TextSizingExample. I’m going to try implementing what I learned from that, then I’ll ask my question again if that’s not enough to help me cross the finish line. — Charles Jenkins On Sunday, October 5, 2014 at 7:41 AM, Charles Jenkins wrote: I put an important question in a post with too much other information, so I’m not surprised nobody answered it. I need a text editor control that will size itself vertically to contain text as the user types or pastes it in. That means: The text container must size itself vertically to fit the text The text view must size itself vertically to fit the text container The text view must somehow notify its superview that its size has changed. Does anyone know how to do this? What I’ve tried so far is setting the text container’s widthTracksView to YES and pinning the text view to the size of its scroll view, so the widths are handled, I think. But I don’t know where to begin to get the height to resize from the inside out. Thank you! — Charles Jenkins ___ 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: Stack?
On 4 Oct 2014, at 02:06, Charles Jenkins cejw...@gmail.com wrote: Okay, here’s a dumb question… How do you make a stack view actually stack things? When I add subviews into a stack view, instead of appearing one after another as I expect, they’re all laid on top of one another. self.theStack.alignment = NSLayoutAttributeBottom; This might be the cause of your trouble. Just get rid of it. NSStackView is a great control once you get your head around it. You can also embed it in an NSScrollView - https://github.com/mugginsoft/TSStackView/blob/master/TSStackView.m#L452 I normally create a stack like so, populating it with views loaded from a NIB. self.stackView = [NSStackView stackViewWithViews:@[self.titleView, self.view1, self.view2, ] ]; self.stackView.orientation = NSUserInterfaceLayoutOrientationVertical; self.stackView.spacing = 0; Note that NSStackView calls -fittingSize on its subviews. If you have manually added constraints to your subview and they don’t fully constrain the view height (in the above example) then view will collapse to 0 height within the stack view. J ___ 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
Document Based app with SQLite backing store
Hi, I'm learning a bit about Cocoa Desktop development and I'd like to create a Document based app with a SQLite backing store. First of all, the wizard/template does this just fine for me --- but the resulting class, XIB and sqlite store are all called Document. I'd like to change that name ... but when I try renaming things, the app eventually stops coming up. Does anyone know how the datastore is tied to the document so that self.managedObjectContext works? In Xcode 6, the template doesn't even create an App Delegate - so I can't see how the data model is tied to the provided context in Document. Thanks, -Luther ___ 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: A Stack of Editors
On Oct 4, 2014, at 8:49 PM, Charles Jenkins cejw...@gmail.com wrote: Keary, I see you’re right: NSTableViewDelegate’s tableView:heightOfRow: will be key if my stack of editors appears in a table view. I’ve been struggling all day to get a test program to call my delegate’s functions. I must say, the table view is a very disheartening object to work with. John, I am sort of doing a master-detail type of thing. I’m trying to implement my own version of Jer’s Novel Writer. On the left side of the screen, there’ll be an Outline View of a novel’s structure, with chapters and scenes. On the right, a stack of text views. If a single scene is selected in the outline, then the stack will contain one editor. But if a chapter is selected, then there’ll be one editor for each scene within it. (Each scene is stored in a separate RTF file in the document’s package file.) I think my stack can be as large as needed without regard to the window’s height: the whole thing will be contained within a scroll view. I tried working with the NSStackView yesterday, and it would only overlay my subviews on top of one another, rather then presenting them in a vertical column as expected. I created 16 variously sized NSBox objects and used a loop to add each one to the top gravity of the stack view. Because the boxes were different sizes, I could see that they were laid uselessly on top of one another like cards in a deck. Today I’m using the same array of NSBoxes, but trying to put them into a single-column table. My table-manager class acts as both a data source and delegate, and because of breakpoints I know that my data source methods are called as expected, as well as some delegate ones, but the methods important to my needs are never called. The table view is set up as view-based in IB and does not have a fixed row size. However, tableView:viewForColumn:row and tableView:heightOfRow: are never called. I’ve struggled with these all day and still can’t figure out why the methods that matter don’t get called. I copied the prototypes directly from the NSTableView documentation and only renamed some variables. I’ve checked several times that the table is configured to be view-based and has no fixed row size. Assuming I’ve got the prototypes right, can anyone suggest reasons why the table would call some delegate methods, but not the important ones shown below? Sometimes the most obvious issue is the culprit--is the delegate outlet set? If so, are any other delegate methods being called? Note that you might not get a call for certain delegate methods if there is no data to show--i.e. if the table view doesn't otherwise believe it has data to show, either via bindings or data source methods. I suspect, however, that you will have better results from Jonathan's suggestion of a vanilla NSScrollView, especially if you are dealing with fixed numbers of rows. You can have pre-made NSViews that you can swap in and out as its document view. The other types of views (NSTableView, NSStackView, NSCollectionView) are really for dealing with arbitrary numbers of elements, and are probably heavier than you need. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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
Validate NSDocument on Quit
I am trying to prevent a quit in a document-based app when data in a document is invalid. AFAICT when auto save is turned on none of the normal document closing methods are called, and when the app delegate is called, NSDocumentController shows no existing documents. It might also have to do with the Ask to keep changes preference. Has anyone figured out how to trap closing to prevent saving possibly invalid data? TIA, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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: Validate NSDocument on Quit
On Oct 5, 2014, at 7:36 AM, Keary Suska cocoa-...@esoteritech.com wrote: I am trying to prevent a quit in a document-based app when data in a document is invalid. AFAICT when auto save is turned on none of the normal document closing methods are called, and when the app delegate is called, NSDocumentController shows no existing documents. It might also have to do with the Ask to keep changes preference. Has anyone figured out how to trap closing to prevent saving possibly invalid data? This sounds at odds with the fundamental concept of auto-saving, which is that your data is more or less always up to date on disk. Why can’t you write the “invalid” data? It’s the user’s work-in-progress. --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
Re: Validate NSDocument on Quit
On 5 Oct 2014, at 15:36, Keary Suska cocoa-...@esoteritech.com wrote: I am trying to prevent a quit in a document-based app when data in a document is invalid. AFAICT when auto save is turned on none of the normal document closing methods are called, and when the app delegate is called, NSDocumentController shows no existing documents. It might also have to do with the Ask to keep changes preference. Has anyone figured out how to trap closing to prevent saving possibly invalid data? In my own document app I have continuously updating bindings and validations that must be run between numerous fields. Auto saving doesn’t really work in a situation like this unless you also persist the fact that a portion of the data is currently invalid and can configure the app to handle this when loading documents - all of which sounds ghastly. In my case I keep autosaving off. J ___ 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