mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Add method to get rects of clicked items.
This commit is contained in:
parent
96b094be5c
commit
925b6f8e1b
2 changed files with 29 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue