0
我是新來這個技術,我想在Right click
的父節點和子節點顯示不同上下文菜單 ..如何在NSOutlineView中創建右鍵菜單?
我是新來這個技術,我想在Right click
的父節點和子節點顯示不同上下文菜單 ..如何在NSOutlineView中創建右鍵菜單?
子類NSOutlineView
和實施- (NSMenu *)menuForEvent:(NSEvent *)theEvent
。
-(NSMenu*)menuForEvent:(NSEvent*)evt
{
NSLog(@"menuForEvent %@ %@",self, [self delegate]);
NSPoint pt = [self convertPoint:[evt locationInWindow] fromView:nil];
int row=[self rowAtPoint:pt];
// create menu ..
return menu;
}
在Mac OS 10.5以上,在筆尖並設置委託創建NSmenu和實施-(void)menuNeedsUpdate:(NSMenu *)menu
。
http://whathaveyoutried.com&https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSOutlineView_Class/Reference/Reference.html – Dustin 2012-07-20 15:11:02