still wrestling with dynamic columns and column auto-resizing
still wrestling with dynamic columns and column auto-resizing
- Subject: still wrestling with dynamic columns and column auto-resizing
- From: Matt Neuburg <email@hidden>
- Date: Thu, 04 May 2006 17:16:47 -0700
- Thread-topic: still wrestling with dynamic columns and column auto-resizing
In my NSTableView, the user can ask for many columns to come and go. That's
what I mean by "dynamic columns". It's like in the Finder where a pref says
what columns appear in list view, or like in iTunes.
Well, this is turning out to be tremendously difficult.
It all stems from the fact that I want to remember the user's column choices
and column widths after the app quits. When the app starts up, I restore the
appropriate columns dynamically. Except that it wasn't working - I would
command a table column to be added and it wasn't being added. This turned
out to be because of the NSTableView's autosaveName. (We had a thread about
this earlier.) So I deleted the NSTableView's Autosave Name from the nib.
That's when the trouble began.
(1) When I deleted my NSTableView's Autosave Name from the nib, its column
autoresizing behavior completely stopped working. I would resize the window
manually in the running app, and the columns would no longer resize
themselves. Is there a secret rule that all these settings
(columnAutoresizingStyle, resizingMask, etc.) go dead unless the NSTableView
has an autosaveName?
(2) Okay, so I threw up my hands and went back to the old (pre-Tiger) way: I
decided I'd have to resize the columns myself as the user resizes the
window. I registered for, and received, the
NSViewFrameDidChangeNotification. It arrives multiple times as the user
resizes the window. In response, I call sizeToFit and sizeLastColumnToFit on
the table. Nothing happens! The columns don't change size. Is there another
secret rule that you can't change column sizes manually (using these
commands) in the middle of live resizing?
Finally, utterly mystified, I threw up my hands *again* and subclassed
NSTableView so that I could arrange for a notification from
viewDidEndLiveResize. When I get that notification, I call sizeToFit and
sizeLastColumnToFit on the table, and it works! But of course the whole
process looks cruddy, because nothing happens until the user lets go of the
mouse.
So in the end, I do seem to have dynamic columns with saving/restoring of
column choice and width prefs working, but at the sacrifice of live column
resizing. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden