diff --git a/ChangeLog b/ChangeLog index a3ad32a83..2229c6144 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-10-27 Richard Frith-Macdonald + + * Source/NSSavePanel.m: Change to have entire window accept DnD. + * Source/NSWindow.m: Fix to get whole window DnD working, also + to enable propogation of drag events up the view hierarchy to the + first drag-aware view ... not sure that this is correct but it + seems sensible. + 2003-10-27 Richard Frith-Macdonald * Source/NSOpenPanel.m: Allow users to type in an absolute path name. diff --git a/Source/NSSavePanel.m b/Source/NSSavePanel.m index 3f9c9292e..bd129b5de 100644 --- a/Source/NSSavePanel.m +++ b/Source/NSSavePanel.m @@ -92,16 +92,7 @@ static BOOL _gs_display_reading_progress = NO; - (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2; @end /* NSSavePanel (PrivateMethods) */ -@interface PanelView : NSView -{ - NSSavePanel *owner; -} -- (id) initWithFrame: (NSRect)r owner: (NSSavePanel*)p; -- (BOOL) performDragOperation: (id)sender; -- (BOOL) prepareForDragOperation: (id)sender; -@end - -@implementation PanelView +@implementation NSSavePanel (_PrivateMethods) - (unsigned int) draggingEntered: (id )sender { @@ -115,17 +106,6 @@ static BOOL _gs_display_reading_progress = NO; return NSDragOperationAll; } -- (id) initWithFrame: (NSRect)r owner: (NSSavePanel*)p -{ - if ((self = [super initWithFrame: r]) != nil) - { - owner = p; - [self registerForDraggedTypes: [NSArray arrayWithObjects: - NSFilenamesPboardType, nil]]; - } - return self; -} - - (BOOL) performDragOperation: (id)sender { NSArray *types; @@ -138,7 +118,7 @@ static BOOL _gs_display_reading_progress = NO; NSArray *names = [dragPb propertyListForType: NSFilenamesPboardType]; NSString *file = [names lastObject]; - [owner setDirectory: file]; + [self setDirectory: file]; return YES; } return NO; @@ -148,9 +128,7 @@ static BOOL _gs_display_reading_progress = NO; { return YES; } -@end - -@implementation NSSavePanel (_PrivateMethods) + -(id) _initWithoutGModel { NSBox *bar; @@ -158,7 +136,6 @@ static BOOL _gs_display_reading_progress = NO; NSImage *image; NSRect r; id lastKeyView; - id panelView; // Track window resizing so we can change number of browser columns. [[NSNotificationCenter defaultCenter] addObserver: self @@ -177,13 +154,10 @@ static BOOL _gs_display_reading_progress = NO; [self setMinSize: [self frame].size]; r = NSMakeRect (0, 0, 308, 317); - panelView = [[PanelView alloc] initWithFrame: r owner: self]; - [self setContentView: panelView]; - RELEASE(panelView); [[self contentView] setBounds: r]; r = NSMakeRect (0, 64, 308, 245); - _topView = [[PanelView alloc] initWithFrame: r owner: self]; + _topView = [[NSView alloc] initWithFrame: r]; [_topView setBounds: r]; [_topView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable]; [_topView setAutoresizesSubviews: YES]; @@ -191,7 +165,7 @@ static BOOL _gs_display_reading_progress = NO; [_topView release]; r = NSMakeRect (0, 0, 308, 64); - _bottomView = [[PanelView alloc] initWithFrame: r owner: self]; + _bottomView = [[NSView alloc] initWithFrame: r]; [_bottomView setBounds: r]; [_bottomView setAutoresizingMask: NSViewWidthSizable|NSViewMaxYMargin]; [_bottomView setAutoresizesSubviews: YES]; @@ -352,6 +326,9 @@ static BOOL _gs_display_reading_progress = NO; [self setInitialFirstResponder: _form]; [super setTitle: @""]; + [self registerForDraggedTypes: [NSArray arrayWithObjects: + NSFilenamesPboardType, nil]]; + return self; } diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 843fd2c47..b1268e8e9 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -3131,15 +3131,19 @@ Code shared with [NSPanel -sendEvent:], remember to update both places. #define GSPerformDragSelector(view, sel, info, action) \ if ([view window] == self) \ { \ - id target; \ + id target = view; \ \ - if (view == _contentView && _delegate != nil) \ + if (target == _wv) \ { \ - target = _delegate; \ - } \ - else \ - { \ - target= view; \ + if (_delegate != nil \ + && [_delegate respondsToSelector: sel] == YES) \ + { \ + target = _delegate; \ + } \ + else \ + { \ + target = self; \ + } \ } \ \ if ([target respondsToSelector: sel]) \ @@ -3152,15 +3156,19 @@ Code shared with [NSPanel -sendEvent:], remember to update both places. #define GSPerformVoidDragSelector(view, sel, info) \ if ([view window] == self) \ { \ - id target; \ + id target = view; \ \ - if (view == _contentView && _delegate) \ + if (target == _wv) \ { \ - target = _delegate; \ - } \ - else \ - { \ - target= view; \ + if (_delegate != nil \ + && [_delegate respondsToSelector: sel] == YES) \ + { \ + target = _delegate; \ + } \ + else \ + { \ + target = self; \ + } \ } \ \ if ([target respondsToSelector: sel]) \ @@ -3175,9 +3183,14 @@ Code shared with [NSPanel -sendEvent:], remember to update both places. BOOL isEntry; v = [_contentView hitTest: [theEvent locationInWindow]]; + // FIXME ... check whether drag shoulkd propogate up hierarchy + while (v != nil && ((NSViewPtr)v)->_rFlags.has_draginfo == 0) + { + v = [v superview]; + } if (v == nil) { - v = _contentView; + v = _wv; } dragInfo = [GSServerForWindow(self) dragInfo]; if (_lastDragView == v) @@ -3195,7 +3208,7 @@ Code shared with [NSPanel -sendEvent:], remember to update both places. } ASSIGN(_lastDragView, v); _f.accepts_drag = GSViewAcceptsDrag(v, dragInfo); - action = NSDragOperationNone; + action = NSDragOperationNone; } if (_f.accepts_drag) {