Re: Tableview woes
Re: Tableview woes
- Subject: Re: Tableview woes
- From: tony cate <email@hidden>
- Date: Thu, 18 Dec 2003 16:45:43 -0600
Well, the mantra I keep hearing is, if it's seems like it's hard to (in
Cocoa), then you're doing it wrong. Thus, my post.
Basically, I set a double-click action for the table. In that method I
use: editColumn:row:withEvent:select:
Once editing is finished the controlTextDidEndEditing notification
fires and i update my UI. There I've tried deselecting all and then
selecting the row, and I've tried just selecting the row outright with
selectRow:byExtendingSelection.
I've also tried taking the double-click action out and letting the
system initiate editing. Then I can use the mouse with the assertions,
but programmatically selecting the row does get the assertion failure.
Frustrating.
On Dec 18, 2003, at 3:49 PM, J Nozzi wrote:
>
It seems STRANGE that it's this difficult. The -action,
>
-doubleAction, -menu, selectRow:byExtendingSelection:, etc. don't seem
>
to play well together.
>
>
I'm struggling with this issue right now; I have doubleAction set to
>
open a corresponding document, but I want a context menu to select
>
whichever row was ctl- or right-clicked, as I want to provide a
>
context-menu-fired 'edit', since double-click is my 'open this
>
document' action.
>
>
My HEAD hurts!
>
>
- J
>
>
>
On Dec 18, 2003, at 4:09 PM, email@hidden wrote:
>
>
> 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.
>
_______________________________________________
>
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.
_______________________________________________
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.