Re: contextual menu in NSTableView cell
Re: contextual menu in NSTableView cell
- Subject: Re: contextual menu in NSTableView cell
- From: "Rakesh Pandey" <email@hidden>
- Date: Sat, 18 Jan 2003 04:18:34 +0530
You need to create a subclass of NSTextFieldCell and track the mouse in this
by implementing the method
-(BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame
ofView:(NSView *)controlView untiMouseUp:(BOOL)untiMouseUp
{
NSPoint mousePoint = [controlView convertPoint:[theEvent
locationInWindow] fromView:nil];
if (NSPointInRect(mousePoint cellFrame)
{
[self showPopUpWithEvent:theEvent ofView:controlView
cellFrame:cellFrame];
}
else
//do nothing
return YES;
}
Now you will have to creat a contextual Menu do it in showPopUpWithEvent
method:
-(void)showPopUpWithEvent:(NSEvent*)theEvent ofView:(NSView *)controlView
cellFrame:(NSRect *)inCellFrame
{
//Create a menu here ...say your menu object is aenu
[NSMenu popUpContextMenu:aMenu withEvent:theEvent
forView:controlView];
}
Now You will have to create an instance of this cell and attach it to your
table column as you had done with NSButtonCell in your last query.
Hope it helps.
regards
Rakesh
----- Original Message -----
From: "stupidFish programming" <email@hidden>
To: <email@hidden>
Sent: Saturday, January 18, 2003 3:35 AM
Subject: contextual menu in NSTableView cell
>
hi,
>
>
i want to have a contextual menu to pop-up when ctrl-clicked on a
>
table's given cell.
>
i tried to do the following:
>
>
- (void)tableView:(NSTableView *)view willDisplayCell:(id)cell
>
forTableColumn:(NSTableColumn *)col row:(int)row
>
{
>
[cell setMenu:theMenu];
>
}
>
>
but it doesn't give me a the menu. am I completely in the wrong
>
direction?
>
>
Ben
>
_______________________________________________
>
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.