Re: Tableview woes
Re: Tableview woes
- Subject: Re: Tableview woes
- From: email@hidden
- Date: Thu, 18 Dec 2003 13:09:45 -0800
Could you post the code you are using? Maybe that will help too.
I'm interested in the answer to this question too, as I've been getting
the same error recently and have been unable to determine the root
cause either. I would like to add my situation to this discussion and
hope we can solve both of our problems.
In my app, I want to tab into a table from an NSTextField. If there is
no previously selected row, I want the first cell of the first row
selected and ready for editing (i.e., I want the user to be able to tab
into the table and start typing in the first cell and not have to click
the mouse). If there is a previously selected row, I want to select the
first cell in that row.
The problems:
The first time I tab into the table (no row has been selected by user
yet) the row is selected, the first cell is highlighted with a blue
ring, but the cell is not set up to edit. I have to click the mouse in
the cell to get a cursor before I can type. I want to correct the code
so the user can immediately start typing in the cell without clicking
the mouse.
Sometimes when I click on another row, I get the assertion
failure/exception message listed below.
When I tab into the table later, when a row other than the first row
has been previously selected and is grey, I get the assertion
failure/exception message listed below. If the first row is the
previously selected grey row the text in the cell is highlighted in
light grey and won't accept typing.
Here is the code I use to select the row. It is in my custom subclass
of NSTableView:
// overriding this NSView method allows the user to tab into the table
- (BOOL) needsPanelToBecomeKey {
// if there is no row selected, go to top left cell, otherwise edit
first cell in selected row
if ([self selectedRow] == -1) {
[self selectRow: 0 byExtendingSelection: NO];
[self editColumn: 0 row: 0 withEvent: nil select: YES];
}
else {
[self selectRow: [self selectedRow] byExtendingSelection: NO];
[self editColumn: 0 row: 0 withEvent: nil select: YES];
}
return YES;
}
// overriding this NSResponder method is needed because
NSView:needsPanelToBecomeKey was overridden
- (BOOL) acceptsFirstResponder {
return YES;
}
If I delete the else clause in needsPanelToBecomeKey, I don't get the
assertion failure/exception message.
My error is very similar to yours, just a different line number at the
end of the first message:
2003-12-18 12:19:38.266 myApp[502] *** Assertion failure in
-[ICTableView editColumn:row:withEvent:select:],
TableView.subproj/NSTableView.m:2434
2003-12-18 12:19:38.267 myApp[502] Exception raised during posting of
notification. Ignored. exception: Invalid parameter not satisfying:
_lastSelectedRow == row
Obviously I need to make some changes in my approach and would
appreciate any suggestions.
On Wednesday, December 17, 2003, at 06:33 PM, tony cate wrote:
>
On Dec 17, 2003, at 8:04 PM, Laurent Daudelin wrote:
>
>
> on 17/12/03 18:22, tony cate at email@hidden wrote:
>
>
>
>> In iTunes, you can double-click a table entry to edit it. When you
>
>> hit
>
>> enter, the edit is accepted, the list sorts, and the edited entry is
>
>> selected.
>
>>
>
>> I want to do that. When I try to programmatically deselect the
>
>> selected
>
>> row or select a new row, I get an assertion failure.
>
>>
>
>> I did a Mamasam search on assertion failure and found a note about
>
>> getting into editing via selectRow... and setting the event to nil. I
>
>> did try that, but I still get assertion failures. This seems like it
>
>> should be pretty simple, so I'm sure I've just overlooked something.
>
>> Hints would be greatly appreciated.
>
>
>
> It might help if you could post the exact assertion failure you're
>
> getting...
>
>
>
> -Laurent.
>
>
>
>
Good point. Here it is:
>
>
*** Assertion failure in -[NSTableView
>
editColumn:row:withEvent:select:], > TableView.subproj/NSTableView.m:2754
>
2003-12-17 20:31:16.640 MyApplication[3314] Exception raised during
>
posting of notification. Ignored. exception: Invalid parameter not
>
satisfying: _lastSelectedRow == row
>
>
Tony
_______________________________________________
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.