From f45db5383dc6c0c7c565c688ae2f0238e74f3ff4 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 6 Sep 2020 11:25:59 -0400 Subject: [PATCH] only show the media drag handle when moused over. --- Ample/Base.lproj/MediaView.xib | 11 ++++++----- Ample/MediaViewController.h | 2 +- Ample/MediaViewController.m | 20 +++++++++++++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Ample/Base.lproj/MediaView.xib b/Ample/Base.lproj/MediaView.xib index 7dae8c1..13d114f 100644 --- a/Ample/Base.lproj/MediaView.xib +++ b/Ample/Base.lproj/MediaView.xib @@ -17,7 +17,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -101,13 +101,14 @@ - - + + diff --git a/Ample/MediaViewController.h b/Ample/MediaViewController.h index 89ce151..36103ce 100644 --- a/Ample/MediaViewController.h +++ b/Ample/MediaViewController.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @interface TablePathView : NSTableCellView @property (weak) IBOutlet NSPathControl *pathControl; @property (weak) IBOutlet NSButton *ejectButton; - +@property (weak) IBOutlet NSImageView *dragHandle; @end NS_ASSUME_NONNULL_END diff --git a/Ample/MediaViewController.m b/Ample/MediaViewController.m index 40b29db..570bbc3 100644 --- a/Ample/MediaViewController.m +++ b/Ample/MediaViewController.m @@ -9,7 +9,25 @@ #import "MediaViewController.h" -@implementation TablePathView +@implementation TablePathView { + NSTrackingRectTag _trackingRect; +} + +-(void)viewDidMoveToSuperview { + if (_trackingRect) { + [self removeTrackingRect: _trackingRect]; + } + NSRect rect = [_dragHandle frame]; + _trackingRect = [self addTrackingRect: rect owner: self userData: NULL assumeInside:NO]; +} + +-(void)mouseEntered:(NSEvent *)event { + [_dragHandle setHidden: NO]; +} + +-(void)mouseExited:(NSEvent *)event { + [_dragHandle setHidden: YES]; +} @end