• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Q] doubleAction on a NSTableView misbehaving?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] doubleAction on a NSTableView misbehaving?


  • Subject: Re: [Q] doubleAction on a NSTableView misbehaving?
  • From: Eric Gorr <email@hidden>
  • Date: Thu, 2 Apr 2009 16:00:00 -0400


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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [Q] doubleAction on a NSTableView misbehaving?
      • From: Corbin Dunn <email@hidden>
References: 
 >[Q] doubleAction on a NSTableView misbehaving? (From: Eric Gorr <email@hidden>)
 >Re: [Q] doubleAction on a NSTableView misbehaving? (From: Quincey Morris <email@hidden>)
 >Re: [Q] doubleAction on a NSTableView misbehaving? (From: Eric Gorr <email@hidden>)

  • Prev by Date: re: core data, opening a previously saved xml file... bug/glitch/unexpected behavior
  • Next by Date: Re: [Q] doubleAction on a NSTableView misbehaving?
  • Previous by thread: Re: [Q] doubleAction on a NSTableView misbehaving?
  • Next by thread: Re: [Q] doubleAction on a NSTableView misbehaving?
  • Index(es):
    • Date
    • Thread