On Apr 2, 2009, at 3:28 PM, Eric Gorr wrote:


On Apr 2, 2009, at 2:34 PM, Quincey Morris wrote:

On Apr 2, 2009, at 11:11, Eric Gorr wrote:

The documentation for setDoubleAction on a NSTableView states:

  If the double-clicked cell is editable, this message isn’t sent
  and the cell is edited instead.

However, the behavior I am seeing is that although my double- clicked cell is editable (tableView:shouldEditTableColumn:row: does return YES), the selector I passed to setDoubleAction is called when I double click on the cell.

I can only edit the cell if I first click on the cell, pause for about 1 second, and click again.

The fact that a double-click on an editable cell doesn't start an edit when doubleAction has been assigned looks like a bug to me or the documentation is wrong or I have misinterpreted something.

Anyone care to comment?


Yes, if I don't assign something to doubleAction and double click the cell, I can edit.

From the Leopard developer release notes:

"NSTableView/NSOutlineView - Single click to editNSTableView and NSOutlineView now behave like Finder and allow a single click to put it into edit mode. This is done by calling - hitTestForEvent:inRect:ofView: and checking if the cell returns NSCellHitEditableTextArea. This allows you to set a doubleAction and perform some different task when the doubleAction is invoked (for instance, Finder opens files on a double click, and edits via a single click). If the doubleAction is not set, editing is still allowed via a double click."

Thanks.

So, it doesn't seem possible to, for example, avoid have the doubleAction invoked if -hitTestForEvent:inRect:ofView: returns NSCellHitEditableTextArea.

I would still like the edit to start if the user double-clicks on the editable part of the cell, but the doubleAction invoked if they do not.

I have a cell consisting of an image and some text. This cell is a subclass of NSTextFieldCell.

Actually, what appears to work well is:

- (void) handleDoubleClickOnListView:(id)sender
{
    NSEvent       *currentEvent   = [NSApp currentEvent];
    NSInteger     column          = [resourcesList clickedColumn];
    NSInteger     row             = [resourcesList clickedRow];
MyCellClass *theCell = (MyCellClass*)[resourcesList preparedCellAtColumn:column row:row]; NSRect cellFrame = [resourcesList frameOfCellAtColumn:column row:row]; NSUInteger hitTestResult = [theCell hitTestForEvent:currentEvent inRect:cellFrame ofView:resourcesList];

if ( ( hitTestResult & NSCellHitEditableTextArea ) == NSCellHitEditableTextArea ) { if ( [self tableView:resourcesList shouldEditTableColumn: [[resourcesList tableColumns] objectAtIndex:column] row:row] ) { [resourcesList editColumn:column row:row withEvent:currentEvent select:YES];
        }
    }
else if ( ( hitTestResult & NSCellHitContentArea ) == NSCellHitContentArea ) {
    }
}


Basically, I just have the double click method start the edit if needed.




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to