Re: NSTableView corrupts the last column
Re: NSTableView corrupts the last column
- Subject: Re: NSTableView corrupts the last column
- From: Devin Lane <email@hidden>
- Date: Mon, 20 Oct 2003 17:43:37 -0700
John
Sorry, I didn't mean for you to create the extra column with code, I
meant for you to do it in IB. Then, you can implement the delegate
method and prevent selection of the column. In your datasource, just
return @"" for the extra column. You can also implement the method
that controlls selection and editing of cells to, again, prevent
interaction with this column. Other than that, i cannot think of any
other way to do it. You are right, however, the Finder is carbon,
therefore none of its controls are NSanything. They are all carbon
stuff which is much more complicated, but more flexible (I think).
Hope this works,
-- Devin Lane, Cocoa Programmer
email: email@hidden
On Oct 19, 2003, at 9:45 PM, John Nairn wrote:
>
Devin,
>
It comes close, but it is very klunky and not really correct
>
(i.e. not really like Apple's finder):
>
>
When my table is created, I added an extra column with
>
>
obj=[[NSTableColumn alloc] initWithIdentifier:[NSNumber
>
numberWithInt:-1]];
>
[[obj headerCell] setStringValue:@""];
>
[table addTableColumn:obj];
>
[obj release];
>
[table sizeLastColumnToFit];
>
>
This is almost OK, but has minor and serious problems and still does
>
not reproduce Apple's Finder:
>
>
1. (minor) - it requires ugly code. I had to write extra code in all
>
table methods to do something different when called for the fake extra
>
column. I would think there would be a better Cocoa approach.
>
>
2. (major) - my table allows dragging columns to reorder them and the
>
coordination with data is handled in a method that observes
>
"NSTableViewColumnDidMoveNotification". I tried special case to find
>
move involving the fake extra column, but it does not work to move
>
back with NSTableView moveColumn method because that posts another
>
"NSTableViewColumnDidMoveNotification" involving the extra column
>
resulting in a endless loop and eventual crash.
>
>
3. (minor) - although I implemented tableView:shouldSelectTableColumn:
>
to block the extra column, a user can still click in the header of
>
last cell, it hilights, and interferes with prior column header
>
hilighting (without more special case code).
>
>
Again, Apple's Finder has none of these problems (unless their code is
>
ugly). The column can not be dragged beyond the last column and
>
clicking in the header after the last real column does not hilight
>
that zone.
>
>
Maybe Apple is not even using NSTableView for list view in the Finder?
>
I noticed that dragging Finder columns looks different than dragging
>
NSTableView columns.
>
>
>
On Sunday, October 19, 2003, at 06:43 PM, Devin Lane wrote:
>
>
> John
>
>
>
> Ah, I see now. At first, I misunderstood what you wanted. I think
>
> the trick is to actually create another column to the right of the
>
> columns you actually have data for. The only thing you have to
>
> implement now is tableView:shouldSelectTableColumn: and return NO for
>
> the extra column. Make sure to turn off Autoresizes Columns to Fit.
>
>
>
> Hopefully, that is what you are looking for. Otherwise, I think you
>
> will have to implement some custom resizing code :(
>
>
>
>
>
> -- Devin Lane, Cocoa Programmer
>
> email: email@hidden
>
> On Oct 19, 2003, at 5:16 PM, John Nairn wrote:
>
>
>
>> Devin,
>
>>
>
>> Thanks for the input. Your idea would help but only if I can not do
>
>> what I really want to do. I am trying to write a better question for
>
>> the discussion group, but basically I want my interface to be like
>
>> the list view in Apple's finder (so it really must be possible?). In
>
>> that view the last column does not change size when a window is
>
>> resized. It ONLY changes if you drag a line between columns in the
>
>> table header. If I could accomplish the same it would be great, but
>
>> nothing I have tried can do it.
>
>>
>
>> My application will create these tables programmatically in response
>
>> to user settings for numbers of columns, information for each
>
>> columns, and the width of each column, etc.. I assume I could set a
>
>> minimum or maximum size as you suggested programmatically, but I
>
>> have no way of knowing in advance what each user will want. The real
>
>> answer is the interface I want (like Apple's Finder), but I do not
>
>> seem to be able to accomplish it with NSTableView.
>
>>
>
>> If you have an other ideas, I would like to hear. I may also post a
>
>> new questions soon after trying a few things in a mini projects that
>
>> duplicates all the problems. For example, I set the table in
>
>> Interface Builder to NOT allow resizing of columns at all and the
>
>> last column still resizes due to window changes (and posts all
>
>> resizing notifications). This example sounds like a bug in
>
>> NSTableView to me. In my opinion resizing the window should never
>
>> resize the column sizes unless you want all columns to be sized to
>
>> fit the window. I want to allow the table to be larger than the
>
>> window.
>
>>
>
>> On Saturday, October 18, 2003, at 08:27 PM, Devin Lane wrote:
>
>>
>
>>> John
>
>>>
>
>>> You can set limits to the size of table columns. Just go into IB,
>
>>> and click till the table column is selected. Then switch to the
>
>>> size inspector, and set a minimum or maximum. Now, when you
>
>>> resize, the last column will not get so small. Also, make sure to
>
>>> turn on the "Autoresize Table Columns" option for the table view.
>
>>>
>
>>>
>
>>> -- Devin Lane, Cocoa Programmer
>
>>> email: email@hidden
>
>>> On Oct 15, 2003, at 8:23 AM, John Nairn wrote:
>
>>>
>
>>>> I have NSTableView in right half of split view. All works fine, but
>
>>>> whenever the window is resized or the split view is resized and the
>
>>>> last column is visible, the NSTableView automatically resizes the
>
>>>> last
>
>>>> column to fill all remaining space. It continuously posts
>
>>>> NSTableViewColumnDidResizeNotification's during the size change.
>
>>>> This
>
>>>> behavior leads to two bad problems:
>
>>>>
>
>>>> 1. When reducing the window size the size of the last column
>
>>>> shrinks
>
>>>> down to a few pixels. It can no longer be viewed by scrolling and I
>
>>>> have to scroll to edge and then enlarge the window (which resizes
>
>>>> the
>
>>>> oclumn again) to see it all (i.e., it takes two annoying steps to
>
>>>> reveal it again).
>
>>>>
>
>>>> 2. If I manually reduce the last column, sometimes (but not
>
>>>> always) it
>
>>>> will be left alone but then the table header cells do not draw
>
>>>> correctly. They draw OK over actual columns but there is ugly
>
>>>> white gap
>
>>>> between last table cell end scroll bars.
>
>>>>
>
>>>> Perhaps this is planned NSTableView behavior, but in my opinion,
>
>>>> the
>
>>>> user should decide when to resize columns by deliberately resizing
>
>>>> or
>
>>>> dragging of columns; resizing windows or split panes should not
>
>>>> lead to
>
>>>> unexpected column size changes. I suspect Apple agrees because the
>
>>>> NSTableView in the Finder's List View works exactly as I want my
>
>>>> table
>
>>>> to work. The last column size stays the way you set it no matter
>
>>>> how
>
>>>> you resize the window. You change its size by the proper method
>
>>>> dragging columns.
>
>>>>
>
>>>> How can I make the columns in my table work like the table in
>
>>>> Finder's
>
>>>> list view? I would think that would be the default behavior?
>
>>>>
>
>>>> ----------------
>
>>>> John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
>
>>>> Web page: http://www.mse.utah.edu/~nairn
>
>>>> _______________________________________________
>
>>>> cocoa-dev mailing list | email@hidden
>
>>>> Help/Unsubscribe/Archives:
>
>>>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
>>>> Do not post admin requests to the list. They will be ignored.
>
>>>>
>
>>>
>
>>>
>
>> ----------------
>
>> John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
>
>> Web page: http://www.mse.utah.edu/~nairn
>
>>
>
>>
>
>
>
>
>
----------------
>
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
>
Web page: http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.