Skip to content

Commit c6f19e2

Browse files
Make DragFileView a subclass of NSBox
- Has same visual appearance - Does not need to access underlying CALayer - Prepares for Mojave Dark Mode (Issue #22)
1 parent 166fef2 commit c6f19e2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

BuildSettingExtractor/DragFileView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <Cocoa/Cocoa.h>
1010

1111
IB_DESIGNABLE
12-
@interface DragFileView : NSView
12+
@interface DragFileView : NSBox
1313

1414
@property (readonly) NSURL *fileURL;
1515

BuildSettingExtractor/DragFileView.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ @interface DragFileView ()
1818
@implementation DragFileView
1919

2020
- (void)commonInit {
21-
self.wantsLayer = YES;
21+
self.boxType = NSBoxCustom;
22+
self.cornerRadius = 20.0;
23+
self.borderWidth = 0.0;
2224
[self setHighlight:NO];
23-
self.layer.cornerRadius = 20.0;
2425
[self registerForDraggedTypes:@[(NSString *)kUTTypeFileURL]];
2526
}
2627

@@ -34,9 +35,9 @@ - (instancetype)initWithFrame:(NSRect)frameRect {
3435

3536
- (void)setHighlight:(BOOL)flag {
3637
if (flag) {
37-
self.layer.backgroundColor = [[NSColor colorWithCalibratedRed:0.56 green:0.7 blue:0.81 alpha:1.0] CGColor];
38+
self.fillColor = [NSColor colorWithCalibratedRed:0.56 green:0.7 blue:0.81 alpha:1.0];
3839
} else {
39-
self.layer.backgroundColor = [[NSColor colorWithCalibratedRed:0.7 green:0.85 blue:1.0 alpha:1.0] CGColor];
40+
self.fillColor = [NSColor colorWithCalibratedRed:0.7 green:0.85 blue:1.0 alpha:1.0];
4041
}
4142
}
4243

0 commit comments

Comments
 (0)