Re: sheets and drawers
Re: sheets and drawers
- Subject: Re: sheets and drawers
- From: Matt Neuburg <email@hidden>
- Date: Wed, 14 Jun 2006 10:39:54 -0700
- Thread-topic: sheets and drawers
On Wed, 14 Jun 2006 15:26:32 +0200, Norbert Heger <email@hidden> said:
>
>On Jun 13, 2006, at 20:14, Matt Neuburg wrote:
>
>> When a window has a drawer and you open a sheet on it, don't you
>> think the
>> stuff in the drawer should be disabled? My experience is that it is
>> not. Is
>> it just me?
>>
>> I mean to say, a sheet is supposed to be window-modal (meaning you
>> have to
>> deal with the sheet before you can deal with anything in the
>> window); a
>> drawer, surely, should not be a sneaky way around this. Yet it
>> appears to be
>> just that.
>
>It seems you've discovered an AppKit bug. Fortunately it can be
>easily fixed by adding these few lines to your project:
>
>-------------------------------------------------------------------
>@interface NSDrawerWindow : NSWindow
>- (NSWindow *)_parentWindow;
>@end
>
>@implementation NSDrawerWindow (AttachedSheetBugfix)
>- (NSWindow *)attachedSheet { return [[self _parentWindow]
>attachedSheet]; }
>@end
>-------------------------------------------------------------------
>
>
>NSWindow invokes [self attachedSheet] in order to determine if an
>event shall be processed or not. If there is a sheet attached, the
>event will be ignored. However, NSDrawerWindow (a private subclass of
>NSWindow) always returns nil for "attachedSheet", since the sheet is
>not attached to the drawer but to its parent window.
>
>The above category fixes this issue by implementing -[NSDrawerWindow
>attachedSheet] and returning the parent window's attached sheet.
>
>I've filed a bug (radar://4585685).
Oddly, this fix is not sufficient to prevent drag-and-drop. I wonder whether
there is also another AppKit bug, that drag-and-drop keeps working in the
window that is partly obscured by the sheet.
In particular, I have a text field in the drawer, and I want to block
dragging to it when the sheet is down.
If the text field is not being edited, I am able to block the drag in
draggingEntered:, like this:
if ([[self window] attachedSheet]) return NSDragOperationNone;
This shows that your fix is working (because the value of attachedSheet
isn't nil). However, I feel I should not have to do this; drag and drop
should stop working all by itself, and it doesn't.
Furthermore, if the text field *is* already being edited when the sheet came
down, I'm helpless. The text field is disabled, but drag and drop into it
still works! That seems very wrong. I've implemented an NSTextView subclass
that's acting as the field editor, and in draggingEntered: I'm testing
[[[self delegate] window] attachedSheet], but for some reason it's always
nil. I don't know why this is; the delegate is the right delegate and the
window is the NSDrawerWindow, so it ought to work. But it doesn't.
In the end, I had to solve this wing of the problem by calling
makeFirstResponder:nil as I start to show the sheet, but it seems to me that
this should not be necessary.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden