How to show contextual menu of buttoncell in tableview?
How to show contextual menu of buttoncell in tableview?
- Subject: How to show contextual menu of buttoncell in tableview?
- From: Justin Hawkwood <email@hidden>
- Date: Thu, 19 Apr 2007 15:54:17 -0700
Using IB I set a NSButtoncell to the dataCell of a tablecolumn. Also
using IB, I set that buttonCell's menu to an NSMenu. I cannot get
this menu to pop up. On rightClicking the button, nothing happens.
I subclasses tableview to catch the rightMouseDown and rightMouseUp,
and pass the event on to the buttoncell as follows:
- (void)rightMouseDown:(NSEvent *)theEvent
{
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location
fromView:nil];
int col = [self columnAtPoint:local_point];
int row = [self rowAtPoint:local_point];
if ((col >= 0) && (row >= 0) && ([[[[self tableColumns]
objectAtIndex:col] identifier]
isEqualToString:@"filePath"])) {
[[[[[self tableColumns] objectAtIndex:col] dataCellForRow:row]
controlView]
rightMouseDown:theEvent];
}
[super rightMouseDown:theEvent];
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location
fromView:nil];
int col = [self columnAtPoint:local_point];
int row = [self rowAtPoint:local_point];
if ((col >= 0) && (row >= 0) && ([[[[self tableColumns]
objectAtIndex:col] identifier]
isEqualToString:@"filePath"])) {
[[[[[self tableColumns] objectAtIndex:col] dataCellForRow:row]
controlView]
rightMouseUp:theEvent];
}
[super rightMouseUp:theEvent];
}
This works to only send the events to the appropriate tableColumn,
but enters some crazy loop where it just continuously repeats the
signal. My first guess is that the signal is just being sent back to
the tableview, which then sends it back to the datacell, and so on.
How do I get the buttonCell's menu to pop up on right mouse click (or
OPTION-left mouse click)?
~ Justin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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