Re:(new problem) Selecting item in NSTableView when right-clicked on...
Re:(new problem) Selecting item in NSTableView when right-clicked on...
- Subject: Re:(new problem) Selecting item in NSTableView when right-clicked on...
- From: Nils Hjelte <email@hidden>
- Date: Tue, 26 Aug 2003 00:40:18 +0200
On mendag, aug 25, 2003, at 17:41 Europe/Stockholm, Nils Hjelte wrote:
I have an NSTableView with an contextmenu attached to it. When the
user right-clicks on an item in the NSTableView the contextmenu is
brought up correctly, but I also want the clicked cell to be selected.
Is there some cleaner/better way of doing this than to subclass
NSTableView and tracking mouse events?
// Nils Hjelte
Ok, so I subclassed NSTableView and implemented the rightMouseDown
method. To select the row I simulate a left-mouseclick and then
continue with the right-mouseclick. The method looks like this:
- (void)rightMouseDown:(NSEvent *)theEvent
{
/* Simulate a click with left mouse button to select row */
[super mouseDown:theEvent];
[super mouseUp:theEvent];
/* Continue with right-click to bring up context-menu */
[super rightMouseDown:theEvent];
}
This doesn't work though. The problem is when I right-click an item in
the table view it correctly selects the item, but it doesn't bring up
the context-menu until I make a new left-click in the table view. What
should I do?
// Nils Hjelte
_______________________________________________
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.