Re: View-based outline view problem
On Jul 11, 2014, at 12:54 AM, Shane Stanley sstan...@myriad-com.com.au wrote: I'm still not quite out of the woods. In my cell-based outline view, when the user selects an item and hits return to edit it, I change the selection so that only the file name before the extension was selected. I do that with text view delegate methods in my outline view subclass, but that doesn't work with the view-based version. Is there some simple alternative? Have you connected the delegate outlet of your text view (field?)? Regards, Ken ___ 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: View-based outline view problem
On Jul 10, 2014, at 23:34 , Ken Thomases k...@codeweavers.com wrote: Have you connected the delegate outlet of your text view (field?)? This was my first thought, too, but: 1. The delegate method ‘control:textShouldBeginEditing:’ seems like it’s called too late. Presumably the selection change needs to be done when the text field gets first responder status, not when the text is actually changed. 2. It’s not obvious to me how the text field gets first responder status. In the TableViewPlayground sample code, it does, without any apparent support, so I assume this is something built into NSOutlineView - NSTableViewCell - textField outlet (when you press Return). I don’t know how you’d customize that if you have a non-standard table cell view. In particular, I don’t see how you’d know *when* this was happening. I guess you could solve it with a NSTextField subclass that overrides becoming first responder. Or is there a more direct solution, do you think? ___ 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: View-based outline view problem
On 11 Jul 2014, at 4:34 pm, Ken Thomases k...@codeweavers.com wrote: Have you connected the delegate outlet of your text view (field?)? Yes. On 11 Jul 2014, at 4:54 pm, Quincey Morris quinceymor...@rivergatesoftware.com wrote: 1. The delegate method ‘control:textShouldBeginEditing:’ seems like it’s called too late. Presumably the selection change needs to be done when the text field gets first responder status, not when the text is actually changed. Right, that's what I tried and that's what I'm seeing. 2. It’s not obvious to me how the text field gets first responder status. In the TableViewPlayground sample code, it does, without any apparent support, so I assume this is something built into NSOutlineView - NSTableViewCell - textField outlet (when you press Return). I don’t know how you’d customize that if you have a non-standard table cell view. In particular, I don’t see how you’d know *when* this was happening. FWIW, in my cell-based version I used textView:willChangeSelectionFromCharacterRange:toCharacterRange: in my outline view subclass. But that no longer seems to get called. I guess you could solve it with a NSTextField subclass that overrides becoming first responder. That's all I can think of. Just seems a lot of work for something that doesn't strike me as an uncommon need. -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On 11 Jul 2014, at 5:24 pm, Shane Stanley sstan...@myriad-com.com.au wrote: I guess you could solve it with a NSTextField subclass that overrides becoming first responder. That's all I can think of. Well not quite. I'm already overriding keyDown: in the outline view to show QL previews, so it might be easier to hang it off there. But it seems a bit icky. -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On Jul 11, 2014, at 00:24 , Shane Stanley sstan...@myriad-com.com.au wrote: Just seems a lot of work for something that doesn't strike me as an uncommon need. In such a case, it’s also worth re-considering your UI at a higher level. I wonder, for example, whether there’s an alternative that uses *two* text fields. Put the file name in the ‘textField’ outlet field, and put the extension in a separate but adjacent field. Use auto-layout to keep both fields sized to their contents, and to keep the second field immediately adjacent to the first. If that’s actually possibly, it’ll look like a single string when not being edited, but will change the UI so that editing of the pieces is separate. (Or make the extension field uneditable, if you don’t actually allow it to be changed.) It might even be *better* than the old way. :) Something like that. ___ 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: View-based outline view problem
On 11 Jul 2014, at 5:44 pm, Quincey Morris quinceymor...@rivergatesoftware.com wrote: In such a case, it’s also worth re-considering your UI at a higher level. I wonder, for example, whether there’s an alternative that uses *two* text fields. Put the file name in the ‘textField’ outlet field, and put the extension in a separate but adjacent field. Use auto-layout to keep both fields sized to their contents, and to keep the second field immediately adjacent to the first. If that’s actually possibly, it’ll look like a single string when not being edited, but will change the UI so that editing of the pieces is separate. (Or make the extension field uneditable, if you don’t actually allow it to be changed.) It might even be *better* than the old way. :) I'm open to all ideas. But I'm essentially trying to mimic what happens in the Finder, where name+extension can be edited as a unit, but not accidentally. I also want to keep some names unable to be edited at all. Your idea also raises the question of what will be selected when the user presses return and there are two text fields. If I understood how that process happened, I might find a better solution. (And auto-layout is down the track for this .xib -- each time I start playing with that conversion, I seem to end up either crashing Xcode or producing an unreadable .xib. So it's one step into the future at a time.) -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On Jul 11, 2014, at 2:24 AM, Shane Stanley sstan...@myriad-com.com.au wrote: FWIW, in my cell-based version I used textView:willChangeSelectionFromCharacterRange:toCharacterRange: in my outline view subclass. But that no longer seems to get called. In general, an NSCell is owned by a control (instance of some subclass of NSControl). An NSCell uses the field editor, an instance of NSText or a subclass (usually an NSTextView or subclass, more specifically), to handle the actual editing. The field editor uses the control which owns the NSCell as its delegate. That control receives the NSTextViewDelegate and, by extension, NSTextDelegate method calls. Since an NSTextFieldCell is a kind of NSCell, all of the above applies to it, too. In a cell-based outline view, the outline view is the control owning the NSTextFieldCell. There's no actual NSTextField. The text view which is the field editor uses the outline view as its delegate. That's why it gets that delegate method. In your view-based outline view, there's an actual NSTextField (or subclass). That's a control unto itself. So, it (and not the outline view) serves as the field editor's delegate. You can use a custom subclass of NSTextField and it will receive the delegate calls. If you want, you can make your custom NSTextField forward the text view delegate methods to its own delegate. So, your custom text field would not need to incorporate the logic specific to your outline view, it could just be a generic utility class. (I'm a bit surprised that NSTextField doesn't already do this for those NSText[View]Delegate methods which don't already map to NSControlTextDelegate or the informal NSControl delegate methods. Have you tried setting your text field's delegate to your outline view or some appropriate controller?) Regards, Ken ___ 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: View-based outline view problem
On 11 Jul 2014, at 6:37 pm, Ken Thomases k...@codeweavers.com wrote: In general, an NSCell is owned by a control (instance of some subclass of NSControl). An NSCell uses the field editor, an instance of NSText or a subclass (usually an NSTextView or subclass, more specifically), to handle the actual editing. The field editor uses the control which owns the NSCell as its delegate. That control receives the NSTextViewDelegate and, by extension, NSTextDelegate method calls. Since an NSTextFieldCell is a kind of NSCell, all of the above applies to it, too. In a cell-based outline view, the outline view is the control owning the NSTextFieldCell. There's no actual NSTextField. The text view which is the field editor uses the outline view as its delegate. That's why it gets that delegate method. In your view-based outline view, there's an actual NSTextField (or subclass). That's a control unto itself. So, it (and not the outline view) serves as the field editor's delegate. You can use a custom subclass of NSTextField and it will receive the delegate calls. If you want, you can make your custom NSTextField forward the text view delegate methods to its own delegate. So, your custom text field would not need to incorporate the logic specific to your outline view, it could just be a generic utility class. Ken, Thanks for the detailed explanation. I'll look into this approach. (I'm a bit surprised that NSTextField doesn't already do this for those NSText[View]Delegate methods which don't already map to NSControlTextDelegate or the informal NSControl delegate methods. Have you tried setting your text field's delegate to your outline view or some appropriate controller?) Yes, I have, but with no joy. -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On Jul 11, 2014, at 2:54 AM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: I guess you could solve it with a NSTextField subclass that overrides becoming first responder. Or is there a more direct solution, do you think? Yes, that's exactly what I do, and it works. Override -[NSResponder becomeFirstResponder]. In fact, I think of that as the most direct solution. The NSResponder reference document says Subclasses can override this method to update state or perform some action such as highlighting the selection The text fields in table and outline views attempt to become first responder when the user left clicks in them. That's wired into AppKit. This is explained somewhere in the documentation, but I forget where. -- Bill Cheeseman - b...@cheeseman.name ___ 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: View-based outline view problem
In case anyone's following along, I followed Ken's suggestion and made a subclass of NSTextField, and moved my textView:willChangeSelectionFromCharacterRange:toCharacterRange: delegate method there. I also followed Bill's suggestion of overriding becomeFirstResponder so that I could disallow editing of some names. For the editable names I had to include [self selectText:self] before returning YES, or the field rather than the text was selected. I presume I now need to replace outlineView:setObjectValue:forTableColumn:byItem: with an action method triggered by the text field. Thanks for the tips. -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On 11 Jul 2014, at 7:44 am, João Varela joaocvar...@gmail.com wrote: Ithas been officially declared by Apple that cell-based NSOutlineView¹s and NSTableView's are deprecated. Would you care to point to where? I'm not arguing, but you wouldn't think so from the documentation. I see: NSCell-based tables continue to be supported in OS X v10.7 and later, but they’re typically used only to support legacy code. That hints at deprecation at some stage, but I don't see that it has happened yet. First of all my apologies for not having changed the subject of my first email. You can check that formal declaration in the WWDC 2014 video called “What’s new in Cocoa”. Fast forward to 51:00 and you’ll see that formal declaration. Everything that is NSCell- and NSMatrix-based is deprecated or on its way to formal deprecation. HTH João Varela ___ 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: View-based outline view problem
On Jul 10, 2014, at 3:25 AM, Shane Stanley sstan...@myriad-com.com.au wrote: I'm trying to convert a cell-based outline view to view-based. The model is a file wrapper, I'm using a datasource, and it was working fine while cell-based. I changed from a text cell to NSTableCellView, and when I set it up to use bindings for its image view and text field, it also worked OK. But when I try to do it without the bindings, I have no luck. The items all appear with the name Table View Cell and the gear image. I'm about 90% of the way through creating my first view-based source list from scratch, without bindings, and with lots of custom behaviors. I can't answer your question directly because the topic is too large. All I can say from my experience is that it requires a lot of trial-and-error (as an AppleScripter, you're good at that), and close study of the sample code pays big dividends. The sample code projects I relied on include these: Apple's SidebarDemo sample code Apple's SourceView sample code Apple's TableViewPlayground sample code PXSourceList https://github.com/Perspx/PXSourceList -- Bill Cheeseman - b...@cheeseman.name ___ 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: View-based outline view problem
On 10 Jul 2014, at 5:25 pm, Shane Stanley sstan...@myriad-com.com.au wrote: I'm trying to convert a cell-based outline view to view-based. Is there some good reason to change to view-based, or are you doing it just because it seems to be the modern thing? I'd say, if it ain't broke... I've recently gone through a large rewrite of a section of our app to use a view-based rather than a cell-based table, because it gives us a better user interface, but otherwise, given the pain and usual undocumentedness of it (as is usual for a new Cocoa feature), I would not have bothered just for fun. --Graham ___ 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: View-based outline view problem
On Jul 10, 2014, at 8:00 AM, Graham Cox graham@bigpond.com wrote: Is there some good reason to change to view-based, or are you doing it just because it seems to be the modern thing? I'd say, if it ain't broke... I know you addressed your question to Shane, but speaking for myself: I'm writing a new application, which will require Mavericks or newer. I'm deliberately using all the latest Cocoa technology because that's the best way for me to learn it. (I didn't use bindings because I wanted to understand what methods were needed under the hood. I didn't use NSTreeController because I quickly discovered that the few tree-like things a source list needs to do are more easily done without NSTreeController.) Also, specifically with respect to source lists and the custom features I'm implementing, there are some things you can't do with a cell-based outline. I don't recall what those things are, but they are called out in the appropriate reference documents. -- Bill Cheeseman - b...@cheeseman.name ___ 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: View-based outline view problem
On 10 Jul 2014, at 6:37 pm, Bill Cheeseman wjcheese...@gmail.com wrote: All I can say from my experience is that it requires a lot of trial-and-error Thanks, Bill -- I was hoping someone would pipe up and say I forgot to do X. Oh well... On 10 Jul 2014, at 10:00 pm, Graham Cox graham@bigpond.com wrote: Is there some good reason to change to view-based, or are you doing it just because it seems to be the modern thing? I'd say, if it ain't broke... Good question. There's no compelling reason for this one -- but there is for another more complex one, so I thought I'd cut my teeth on the simpler one first. Now I'm thinking of having them extracted... -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
On Jul 10, 2014, at 2:25 AM, Shane Stanley sstan...@myriad-com.com.au wrote: I'm trying to convert a cell-based outline view to view-based. The model is a file wrapper, I'm using a datasource, and it was working fine while cell-based. I changed from a text cell to NSTableCellView, and when I set it up to use bindings for its image view and text field, it also worked OK. But when I try to do it without the bindings, I have no luck. The items all appear with the name Table View Cell and the gear image. I fear I'm doing something basic incorrectly, but I can't see what. My -outlineView:viewForTableColumn:row: is not even getting called, which seems very odd. (And yes, I commented out -outlineView:willDisplayCell:forTableColumn:item:). Any suggestions? Are your outlets connected? Is your delegate object actually set as the table view's delegate? Are the textField and imageView outlets of the NSTableCellView connected to the text field and image view within it? Regards, Ken ___ 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: View-based outline view problem
On Jul 10, 2014, at 00:25 , Shane Stanley sstan...@myriad-com.com.au wrote: I fear I'm doing something basic incorrectly, but I can't see what. My -outlineView:viewForTableColumn:row: is not even getting called, which seems very odd. (And yes, I commented out -outlineView:willDisplayCell:forTableColumn:item:). Any suggestions? You are doing something basic incorrectly. That NSOutlineView delegate method is called ‘outlineView:viewForTableColumn:item:’. ___ 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: View-based outline view problem
On 11 Jul 2014, at 1:56 am, Quincey Morris quinceymor...@rivergatesoftware.com wrote: You are doing something basic incorrectly. That NSOutlineView delegate method is called ‘outlineView:viewForTableColumn:item:’. Sigh. Thank you for restoring my faith in my own stupidity... -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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: View-based outline view problem
I'm still not quite out of the woods. In my cell-based outline view, when the user selects an item and hits return to edit it, I change the selection so that only the file name before the extension was selected. I do that with text view delegate methods in my outline view subclass, but that doesn't work with the view-based version. Is there some simple alternative? -- Shane Stanley sstan...@myriad-com.com.au www.macosxautomation.com/applescript/apps/ ___ 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