Hello all, I am working on implementing a manual behavior on NSTableView's column resizing. Because it also needs to be live resizing (whenever the window or another column is resized), I have subclassed NSTableColumn and overriden `-setWidth:', which will call a delegate, which in turn will call a method that adjusts the size of each column so that they resize the way we want. The same method is called whenever the application window is resized.
The idea, basically, is that the first column is the most important one, and should not be resized until all others are at their minimum size, or, and this is the crucial part, have been hidden. Whenever the window or a column is resized, here is the desired scenario: (Note that column 2 has a fixed size and is thus never mentioned) - Column 5 is resized until it reaches its min width - Column 4 is resized until it reaches its min width - Column 3 is resized until it reaches its min width - Column 5 is hidden - Column 4 is hidden - Column 1 is finally resized until it reaches its minimum width My implementation with `-setWidth:' and its delegate works pretty well, except I have been experiencing a crash. When resizing the window, it works okay. The only thing is that it may crash when resizing another column after that. Here is how I reproduce it: - Resize the window so that at least column 5 is hidden - Resize column 1 again so that column 5 is visible Then, the following crash happens as soon as I release the mouse: *** Assertion failure in -[MyTableColumn _enableResizedPosting] EXC_0001_NAME:NSInternalInconsistencyException EXC_0001_REASON:Invalid parameter not satisfying: _cFlags.resizedPostingDisableCount > 0 Funny thing is that it does not happen if I resize any column to get to the situation where column 5 is hidden. It only works when I resize the window to do so. After different tests, it looks like NSTableColumn is not happy whenever a column is hidden *before* the column resizing happens, but is visible after, when trying to post the "column did resize" notification. It seemed as if when handling the "mouse down" event, the visible columns are initialized/prepared to be resized. This is why, in my NSTableColumn subclass, I tried to override the -mouseDown: method, and there, I would simply iterate over all the columns and unhide them. And guess what? It works! My "resize delegate" will hide the needed columns after that anyway. Obvisouly though, I have a visual glitch where you can see all the columns for a split second (even if they are supposed to be hidden). The problem in the end is that not only do I have a visual glitch, but this also feels like a very hacky/dirty solution, and hence, not the way to go. I feel like I probably should not be trying to hide columns while some others are resized. It works most of the time though, so this is very confusing. Does anyone have any better ideas? Sincerely,-- Thibault Martin-Lagardette _______________________________________________ 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