Add method to get rects of clicked items.

This commit is contained in:
Gregory John Casamento 2020-05-06 04:39:39 -04:00
parent 96b094be5c
commit 925b6f8e1b
2 changed files with 29 additions and 9 deletions

View file

@ -41,12 +41,14 @@
withFrame:(NSRect)frame
inView:(NSView *)view
{
NSLog(@"Entered...");
}
- (void)mouseExited:(NSEvent *)event
withFrame:(NSRect)frame
inView:(NSView *)view
{
NSLog(@"Exited...");
}
- (void) setAllowedTypes: (NSArray *)types
@ -123,14 +125,25 @@
withFrame:(NSRect)frame
inView:(NSView *)view
{
return NSZeroRect;
NSUInteger index = [_pathComponentCells indexOfObject: cell];
NSRect rect = frame;
CGFloat cellwidth = rect.size.width / [_pathComponentCells count];
NSRect result = NSMakeRect(rect.origin.x,
rect.origin.y + (cellwidth * index),
cellwidth,
rect.size.height);
return result;
}
- (NSPathComponentCell *)pathComponentCellAtPoint:(NSPoint)point
withFrame:(NSRect)frame
inView:(NSView *)view
{
return nil;
NSUInteger c = [_pathComponentCells count];
NSUInteger woc = frame.size.width / c;
NSUInteger item = (NSUInteger)point.x / woc;
return [_pathComponentCells objectAtIndex: item];
}
- (NSPathComponentCell *) clickedPathComponentCell

View file

@ -77,6 +77,16 @@ static NSNotificationCenter *nc = nil;
[super dealloc];
}
- (void) mouseEntered: (NSEvent *)event
{
NSLog(@"Entered");
}
- (void) mouseExited: (NSEvent *)event
{
NSLog(@"Exited");
}
- (void) setPathStyle: (NSPathStyle)style
{
[_cell setPathStyle: style];
@ -390,13 +400,10 @@ static NSNotificationCenter *nc = nil;
}
else
{
NSArray *cells = [self pathComponentCells];
NSUInteger c = [cells count];
NSPoint loc = [event locationInWindow];
NSUInteger woc = (NSUInteger)[self frame].size.width / c;
NSUInteger itemClicked = (NSUInteger)loc.x / woc;
[_cell _setClickedPathComponentCell: [cells objectAtIndex: itemClicked]];
NSPathComponentCell *pcc = [_cell pathComponentCellAtPoint: [event locationInWindow]
withFrame: [self frame]
inView: self];
[_cell _setClickedPathComponentCell: pcc];
if (_action)
{
[self sendAction: _action