[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Drag & Drop Problem
From: |
Fred Kiefer |
Subject: |
Re: Drag & Drop Problem |
Date: |
Thu, 01 Nov 2007 22:02:17 +0100 |
User-agent: |
Thunderbird 1.5.0.12 (X11/20060911) |
Andreas Höschler wrote:
>> I tried to reproduce this problem with NSImageView and after removing
>> the check for ([sender draggingSource] != self) in draggingEntered: it
>> is possible to drag onto the same view.
>
> My SRCalendarView is a subclass of NSImageView. I have overwritten (for
> test purposes) the following methods:
>
> - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
> {
> NSLog(@"draggingEntered %@", sender);
> return (NSDragOperationCopy | NSDragOperationLink |
> NSDragOperationMove);
> }
>
> - (void)draggingExited:(id <NSDraggingInfo>)sender;
> {
> NSLog(@"draggingExited %@", sender);
> }
>
> - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
> {
> NSLog(@"prepareForDragOperation...");
> return YES;
> }
>
> - (NSDragOperation)draggingSourceOperationMask
> {
> return (NSDragOperationCopy | NSDragOperationLink |
> NSDragOperationMove);
> }
> - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
> {
> NSPasteboard *thePasteboard = [sender draggingPasteboard];
> NSArray *types = [thePasteboard types];
> BOOL result = ([types firstObjectCommonWithArray:[self pboardTypes]]
> != nil);
> NSLog(@"performDragOperation %d", result);
> return result;
> }
>
> /*- (NSDragOperation)draggingSourceOperationMask
> {
> return _draggingSourceOperationMask;
> }*/
>
> - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
> {
> }
>
> I get draggingExited and draggingEntered, but the drag sign is "Do Not
> Enter" the whole time and when I let it go the drag image slides back.
> No luck! I am stuck!
>
>> This means it isn't a general problem in GNUstep. Either it is related
>> to you specific class or NSDragOperationLink isn't correctly propagated
>> (which would surprise me with current GNUstep code).
>
> I have no idea. I just know that the exact same code works great under
> MacOSX whatever that means.
>
>> I will need more information from your side to make any further progress.
>
> What else can I provide?
>
> Hey, I just dicovered something. I initiate the drag operation when the
> user presses the Ctrl-Key. That's by design (May be I should thing this
> over, but that how all drag and drop works an dall our applications so
> far). If I initiate the drag with the Ctrl-Key pressed and the let the
> Ctrl-Key go while still dragging, the "Do-Not-Enter" sign becomes a
> "Copy" sign and I can successfully drop.
>
> Mac OS X behaves differently here. The drop works with a pressed
> Ctrl-Key. What exactly does a pressed Ctrl-Key mean to GNUstep?
>
Control changes the operation to link, see _updateOperationMask: in
GSDragView.m:
if (mod & NSControlKeyMask)
{
operationMask = NSDragOperationLink;
}
You may influence this behaviour by implementing
ignoreModifierKeysWhileDragging on your dragging source.
It is also possible that you see the wrong cursor due to the code in
_setCursor not being able to determine, which action you want. This is
rather probable, as the code there is programmed optimistically.
Fred