mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 04:50:37 +00:00
Fix select option
This commit is contained in:
parent
dd62ab2d2c
commit
482b78d1ea
3 changed files with 60 additions and 2 deletions
|
@ -54,7 +54,11 @@ extern "C" {
|
|||
- (void) setPathStyle: (NSPathStyle)style;
|
||||
- (NSPathStyle) pathStyle;
|
||||
|
||||
- (NSColor *) backgroundColor;
|
||||
- (void) setBackgroundColor: (NSColor *)backgroundColor;
|
||||
|
||||
- (NSPathComponentCell *) clickedPathComponentCell;
|
||||
|
||||
- (NSArray *) pathComponentCells;
|
||||
- (void) setPathComponentCells: (NSArray *)cells;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
|
||||
- (NSPathComponentCell *) clickedPathComponentCell
|
||||
{
|
||||
return nil;
|
||||
return _clickedPathComponentCell;
|
||||
}
|
||||
|
||||
- (NSArray *) pathComponentCells
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
Boston, MA 02110 USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSNotification.h>
|
||||
|
||||
#import "AppKit/NSPathControl.h"
|
||||
#import "AppKit/NSPathCell.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
|
@ -29,6 +31,13 @@
|
|||
#import "AppKit/NSPasteboard.h"
|
||||
#import "AppKit/NSMenu.h"
|
||||
#import "AppKit/NSOpenPanel.h"
|
||||
#import "AppKit/NSPathComponentCell.h"
|
||||
|
||||
static NSNotificationCenter *nc = nil;
|
||||
|
||||
@interface NSPathCell (Private)
|
||||
- (void) _setClickedPathComponentCell: (NSPathComponentCell *)c;
|
||||
@end
|
||||
|
||||
@implementation NSPathControl
|
||||
|
||||
|
@ -38,6 +47,7 @@
|
|||
{
|
||||
[self setVersion: 1.0];
|
||||
[self setCellClass: [NSPathCell class]];
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +65,12 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_backgroundColor);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setPathStyle: (NSPathStyle)style
|
||||
{
|
||||
[_cell setPathStyle: style];
|
||||
|
@ -228,12 +244,20 @@
|
|||
|
||||
- (void) _doMenuAction: (id)sender
|
||||
{
|
||||
NSArray *cells = [self pathComponentCells];
|
||||
NSUInteger c = [cells count];
|
||||
NSUInteger i = [[sender menu] indexOfItem: sender];
|
||||
NSUInteger ci = (c - i) + 1;
|
||||
NSPathComponentCell *cc = [cells objectAtIndex: ci];
|
||||
|
||||
[_cell _setClickedPathComponentCell: cc];
|
||||
if (_action)
|
||||
{
|
||||
[self sendAction: _action
|
||||
to: _target];
|
||||
}
|
||||
|
||||
|
||||
[self setURL: [cc URL]];
|
||||
[[sender menu] close];
|
||||
}
|
||||
|
||||
|
@ -246,6 +270,18 @@
|
|||
[op setCanChooseFiles: YES];
|
||||
[op setCanChooseDirectories: YES];
|
||||
|
||||
if ([(id)_delegate respondsToSelector: @selector(pathCell:willPopUpMenu:)])
|
||||
{
|
||||
[_delegate pathControl: self
|
||||
willDisplayOpenPanel: op];
|
||||
}
|
||||
|
||||
if ([(id)[_cell delegate] respondsToSelector: @selector(pathCell:willPopUpMenu:)])
|
||||
{
|
||||
[[_cell delegate] pathCell: _cell
|
||||
willDisplayOpenPanel: op];
|
||||
}
|
||||
|
||||
result = [op runModalForDirectory: nil
|
||||
file: nil
|
||||
types: nil];
|
||||
|
@ -309,7 +345,17 @@
|
|||
willPopUpMenu: menu];
|
||||
}
|
||||
}
|
||||
|
||||
if ([_cell delegate])
|
||||
{
|
||||
if ([(id)[_cell delegate] respondsToSelector: @selector(pathCell:willPopUpMenu:)])
|
||||
{
|
||||
[[_cell delegate] pathCell: _cell
|
||||
willPopUpMenu: menu];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[menu popUpMenuPositionItem: [menu itemAtIndex: 0]
|
||||
atLocation: NSMakePoint(0.0, 0.0)
|
||||
inView: self];
|
||||
|
@ -394,3 +440,11 @@
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation NSPathCell (Private)
|
||||
|
||||
- (void) _setClickedPathComponentCell: (NSPathComponentCell *)c
|
||||
{
|
||||
_clickedPathComponentCell = c;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue