亲爱的全部, 我与NSOutline View一起在上次2-3天内执行表内拖放操作,但无法得到我在做错的事, This是我到目前为止,NSOutline View Drag-n-Drop问题
要求, 1 - 我想有一个透明的或有一些背景图像NSoutlineview在我看来,要做到这一点,我需要覆盖NSOutlineView的drawRect方法,这是什么我已经在头文件中做了
@interface MyCustomOutlineView:NSOutlineView{
NSImage *pBackgroundImage;
}
- setBackgroundImage:(NSImage *)pImage;
在源文件中,我只是简单地覆盖的drawRect和一些其他的东西来绘制背景图像或使之透明,这是工作的罚款,
现在,在我看来,我已经宣布NSOutlineView对象那样,
/* * 我的自定义视图将具有能力来绘制梯度和其他效果
*/
@interface OutlineParentView:MyCustomView<NSOutlineDataSource>{
MyCustomOutlineView *pOutlineView;
}
@property(nonatomic,retain)MyCustomOutlineView *pOutlineView;
在源文件中,实现以下的方法,此 方法具d将拖欧米茄下降如下
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteb oard:(NSPasteboard *)pboard{
[self log:@"write Items"];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:items];
[pboard declareTypes:[NSArray arrayWithObject:OutlineViewPrivateDataType]
owner:self];
[pboard setData:data forType:OutlineViewPrivateDataType];
return YES;
}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
{
NSLog(@"validate Drop");
return NSDragOperationEvery;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index{
[self log:@"inside accept drop for NSView "];
return YES;
}
我检查了苹果DragnDrop示例代码执行相关initWIthFrame
#define OutlineViewPrivateDataType "MyOutlinePrivateData"
-(void)InitOutlineView{
NSRect scrollFrame = [self bounds];
NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame:scrollFrame] autorelease];
[scrollView setBorderType:NSNoBorder];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:NO];
[scrollView setAutohidesScrollers:YES];
[scrollView setDrawsBackground: NO];
NSRect clipViewBounds = [[scrollView contentView] bounds];
pOutlineView = [[[CommUICustomOutlineView alloc] initWithFrame:clipViewBounds] autorelease];
NSTableColumn* firstColumn = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease];
ImageTextCell *pCell = [[ImageTextCell alloc]init];
[firstColumn setDataCell:pCell];
[pCell setDataDelegate:self];
[firstColumn setWidth:25];
[pOutlineView addTableColumn:firstColumn];
[pOutlineView setRowHeight:30];
[pOutlineView setDataSource:self];
/* setData delegate implemented in the MyOutlineView to handle some of event in this
interface if i don't write this, then i can't handle the menu event on the
Outlineview
*/
[pOutlineView setDataDelegate:self];
**/* On this line i am getting one warning, saying OutlineParentView doesn't implement
NSOutlineView delegate protocol */**
[pOutlineView setDelegate:self];
[scrollView setDocumentView:pOutlineView];
/* I don't want group row to be highlighted */
[pOutlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[pOutlineView registerForDraggedTypes:
[NSArray arrayWithObjects:OutlineViewPrivateDataType,nil]];
[pOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[self addSubview:scrollView];
[self setAutoresizesSubviews:YES];
[self log:@"Outline view created "];
}
其他重要方法被调用,但不能得到我在做什么错了, 我相信,一些问题与
[pOutlineView setDelegate:自我]
功能,但如何解决这个问题,我,我不“知道,我 从MyTableView到MyOutlineView,最近我才得以在自定义表格视图中执行拖放nDrop最近升级, 剩下的事情都提前 一种做工精细,像数据源等...
谢谢问候 罗汉