【发布时间】:2010-07-14 02:54:24
【问题描述】:
我正在开发一个拖放视图,并在网络上找到了一些拖放操作的处理程序。我想让它在用户将文件拖到拖放区域上时变为蓝色,并在退出拖放区域时再次变为灰色。问题是当您将鼠标拖到它上面或退出它时它没有更新。以下是部分代码:
- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
[[NSColor grayColor] set];
[NSBezierPath fillRect:bounds];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
NSRect bounds = [self bounds];
[[NSColor blueColor] set];
[NSBezierPath fillRect:bounds];
return NSDragOperationCopy;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender {
NSRect bounds = [self bounds];
[[NSColor grayColor] set];
[NSBezierPath fillRect:bounds];
}
感谢您的帮助。
【问题讨论】:
标签: cocoa drag-and-drop nsview redraw nscolor