Re: -draggingEntered: never gets called [solved?]
Re: -draggingEntered: never gets called [solved?]
- Subject: Re: -draggingEntered: never gets called [solved?]
- From: Michael Gardner <email@hidden>
- Date: Tue, 6 May 2008 11:20:03 -0500
On May 6, 2008, at 10:47 AM, I. Savant wrote:
On Tue, May 6, 2008 at 11:34 AM, Michael Gardner
<email@hidden> wrote:
Upon further investigation, I've found that if I call
-registerForDraggedTypes: before adding the view to its parent
window with
-setContentView:, I never get the -draggingEntered: messages. If I
do so
afterwards, everything works properly. Is this expected behavior?
Interesting ... have you placed the call in the view's
-viewDidMoveToSuperview to get this to work?
The first thing I tried was putting the call in the source's -
mouseDown: method, right before the drag operation. Then on a hunch, I
put the call outside the class, with the code that creates the view
and adds it to the window:
NSWindow * window = [[[NSWindow alloc] initWithContentRect:
NSMakeRect(100, 100, 500, 500) styleMask: NSTitledWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask backing:
NSBackingStoreBuffered defer: NO] autorelease];
[windows addObject: window];
[window setTitle: @"MyWindow"];
MyView * view = [[[MyView alloc] initWithFoo: foo bar: bar frame:
NSMakeRect(0, 0, 500, 500)] autorelease];
[view registerMyDraggedTypes];
[window setContentView: view];
[window makeKeyAndOrderFront: self];
[view registerMyDraggedTypes] just does the actual -
registerForDraggedTypes: call with the right argument. Moving that
statement one line down, after [window setContentView], fixes the issue.
As for posting the code, I'm trying to put together a minimal test
case,
but so far I haven't been able to duplicate the problem. There must
be some
relevant difference between the test case and my actual code, but I
haven't
been able to figure out what that is yet.
One thing that occurs to me is to check where you're defining your
custom type. Does it exist before you're registering it or vice-versa?
:-)
It's just a #define statement (#define MyPasteboardType @"application/
x-foo"), so it should get taken care of during preprocessing... as
long as the compiler can see the definition from wherever I'm using
it, that should be enough, right?
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden