Re: Special behavior when double-click NSTableView cell
Re: Special behavior when double-click NSTableView cell
- Subject: Re: Special behavior when double-click NSTableView cell
- From: Ryan Bates <email@hidden>
- Date: Wed, 18 Feb 2004 10:46:20 -0800
If you want a cell to be edited on a double click with table row
selection disabled, try adding these methods to the table's delegate:
// Set as the table's double action
- (void)doubleClickedTable
{
// The table row must be selected to be editable.
// Just select it and deselect it really quickly.
[mainTable selectRow:[mainTable clickedRow]
byExtendingSelection:NO];
[mainTable editColumn:[mainTable clickedColumn] row:[mainTable
clickedRow] withEvent:nil select:YES];
[mainTable deselectRow:[mainTable clickedRow]];
}
- (BOOL)tableView:(NSTableView *)tableView
shouldEditTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
return NO;
}
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)rowIndex
{
return NO;
}
This kind of works, but it's not perfect. What you really should do is
either subclass NSTableView, create your own table view from scratch,
or use an NSMatrix. The problem is, NSTableView is made for row
selection, not cell selection; so, even if you do subclass it, it might
be awkward adding cell selection. NSMatrix on the other hand, handles
cell selection just fine but doesn't support column headers and other
nice NSTableView features.
Ryan
On Feb 18, 2004, at 9:02 AM, Ivan Myrvold wrote:
No, I don't want this behavior. This is the behavior when setting
editable to NO. I want this:
1. I want to click on a cell, and select that cell (like in Excel). I
don't want to have the whole row selected.
2. I want to double-click a cell (not a row), and have an action
started.
Ivan
Pe 18. feb. 2004 kl. 16.36 skrev Laurent Daudelin:
On 18/02/04 09:55, "Ivan Myrvold" <email@hidden> wrote:
I want an NSTableView to have a special behaviour when I
double-click a
cell, i.e. I want it to select the cell (editable is set to YES), as
it
does now, but also to start an action. This will give the user the
feedback that he is starting the action (opening a sheet) based on
the
information in the cell. Do anyone have a hint to how I could make
this
happen?
Start with the 'doubleAction' method.
-Laurent.
--
======================================================================
==
Laurent Daudelin Developer, Multifamily, ESO, Fannie
Mae
mailto:email@hidden Washington, DC,
USA
************************ Usual disclaimers apply
***********************
_______________________________________________
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.
Ivan C Myrvold
OrtopediService AS
Mob. 913 16 356
Tlf. 38 14 45 93
_______________________________________________
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.