3

ビューベースの NSTableview のドラッグ アンド ドロップについていくつか質問があります。

ここに画像の説明を入力ここに画像の説明を入力

  1. ドラッグ アンド ドロップのハイライト色を変更するには?
  2. ドラッグ アンド ドロップの長方形の形状 (幅と高さ) を変更するには?

前もって感謝します

4

1 に答える 1

8

NSTableRowViewサブクラスで次のようなことができるはずです。

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (!self)
        return nil;
    // etc...

    [self setDraggingDestinationFeedbackStyle:NSTableViewDraggingDestinationFeedbackStyleNone];

    return self;
}

- (void)drawDraggingDestinationFeedbackInRect:(NSRect)dirtyRect {
    NSRect drawRect = [self bounds];
    // Tweaking the size of the drawing rectangle...
    aRowRect.size.height--;
    aRowRect.size.width-=2;
    aRowRect.origin.x++;

    NSBezierPath *backgroundPath = [NSBezierPath bezierPathWithRect:drawRect];
    [[NSColor redColor] set];
    [backgroundPath fill];
    [[NSColor greenColor] set];
    [backgroundPath stroke];
}

もちろん、クリスマスをテーマにしたアプリを作成していない場合は、これらの色を変更する必要があります。

于 2013-06-14T03:35:26.720 に答える