Re: A Stack of Editors

2014-10-06 Thread Charles Jenkins
Keary,  

You made me question what I thought I knew, so I went back and changed my 
method returning the number of rows (views) to log its operation so I could 
make sure it was returning 16 as it should. And of course I found it was 
returning 0.

What I previously didn’t know is that the table loads its data as soon as you 
set the data source property. It never occurred to me the table data would be 
loaded before execution of windowDidLoadFromNib ever finished, so I was 
creating stuff in the wrong order. Once I rearranged that function body to set 
the table’s delegate and data source last, after creating everything else 
including all the demo views, everything worked as expected.

So thanks for the good advice!  

--  

Charles


On Sunday, October 5, 2014 at 9:51, Keary Suska wrote:

 On Oct 4, 2014, at 8:49 PM, Charles Jenkins cejw...@gmail.com 
 (mailto:cejw...@gmail.com) wrote:
  
 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.

___

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

2014-10-05 Thread Keary Suska
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

Re: A Stack of Editors

2014-10-04 Thread Keary Suska
On Oct 3, 2014, at 8:27 PM, Charles Jenkins cejw...@gmail.com wrote:

 What I’m trying to make is a scroll view containing a vertical stack of 
 editors for RTF subdocuments. Each of the text views should size itself to 
 fit the width of the scroll view, but grow vertically as much as necessary to 
 display its full content.
 
 The more I think about it, the more I think what I need is a single-column 
 table view within which each cell holds a text editor. But each row, text 
 view, and text container should resize to fit the text held within. How can I 
 achieve that?

View-based NSTableView? There is a way that you can tickle the table view 
into resizing the row although you will have to figure out how and when to 
determine the appropriate size. Another problem to watch put for is whether 
resizing ends the editing session.

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

Re: A Stack of Editors

2014-10-04 Thread John Joyce

 On Oct 4, 2014, at 11:27 AM, Charles Jenkins cejw...@gmail.com wrote:
 
 I just asked a question about the NSStackView, but perhaps I’m looking at the 
 wrong control altogether.  
 
 What I’m trying to make is a scroll view containing a vertical stack of 
 editors for RTF subdocuments. Each of the text views should size itself to 
 fit the width of the scroll view, but grow vertically as much as necessary to 
 display its full content.
 
 The more I think about it, the more I think what I need is a single-column 
 table view within which each cell holds a text editor. But each row, text 
 view, and text container should resize to fit the text held within. How can I 
 achieve that?
 
 —
 
 Charles Jenkins

Are you trying to use NSTextFields or NSTextViews? Either way, you will 
probably want to enable them to scroll as vertical height on a screen is 
limited.
At some point you will probably need to scroll vertically in the RTF document, 
unless you have some limit on the actual amount of text and you know the screen 
size of all users in advance.
You don’t want a window that exceeds the vertical height of a screen and you 
have no way to know what size screen might be used in advance.

NSStackView in a scroll view should be easier in some ways than NSTableView (if 
you want vertical resizing easily)
You could also do a NSSplitView with custom splitters.
However, it really sounds like you should consider a master-detail design if 
possible.
With say a table view to the left that is for selecting a section to work on, 
then the section displayed to the right.
You could also do a master-detail design with NSTabView. (even tabless, using a 
custom tab selector of some sort)
___

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

2014-10-04 Thread Charles Jenkins
Thank you for responding, guys.

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?

//==  
// NSTableViewDelegate methods
//--

// Return view for row  

- (NSView*) tableView:(NSTableView*)tv  
   viewForTableColumn:(NSTableColumn*)tc
  row:(NSInteger)row
{
  return [self viewForRow:row];
}

// Return height of row

- (CGFloat)tableView:(NSTableView*)tv
 heightOfRow:(NSInteger)row
{
  return [self viewForRow:row].frame.size.height;

}



—

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

A Stack of Editors

2014-10-03 Thread Charles Jenkins
I just asked a question about the NSStackView, but perhaps I’m looking at the 
wrong control altogether.  

What I’m trying to make is a scroll view containing a vertical stack of editors 
for RTF subdocuments. Each of the text views should size itself to fit the 
width of the scroll view, but grow vertically as much as necessary to display 
its full content.

The more I think about it, the more I think what I need is a single-column 
table view within which each cell holds a text editor. But each row, text view, 
and text container should resize to fit the text held within. How can I achieve 
that?

—

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