Skip to content

Dragged image from app does not resize properly #4

@mikemcduffie

Description

@mikemcduffie

The dragged item has the same size as the entire app window rather than the image being dragged.

It appears your code is supposed to resize if the item if from the app's window:

                    /* Only resize a fragging item if it originated from one of our windows.  To do this,
                     * we declare a custom UTI that will only be assigned to dragging items we created.  Here
                     * we check if the dragging item can represent our custom UTI.  If it can't we stop. */
                if ( ![[[draggingItem item] types] containsObject:kPrivateDragUTI] ) {

                    NSLog(@"The fragging item did NOT originate from our window!");
                    *stop = YES;

                } else {
                        /* In order for the dragging item to actually resize, we have to reset its contents.
                         * The frame is going to be the destination view's bounds.  (Coordinates are local 
                         * to the destination view here).
                         * For the contents, we'll grab the old contents and use those again.  If you wanted
                         * to perform other modifications in addition to the resize you could do that here. */

                NSLog(@"The fragging item originated from our window!");
                    [draggingItem setDraggingFrame:self.bounds contents:[[[draggingItem imageComponents] objectAtIndex:0] contents]];
                }

I added the NSLog statements to test whether the resize was attempted. If I'm reading the code correctly, items dragged form the app should invoke the resize. What I see happen with an ordinary JPG file is the IF block runs when an image dragged into the app (as expected), but the ELSEblock does not appear to run if the image is dragged out to the finder.

I'm perplexed as one or the other should always run but the NSLog statement in the ELSE block doesn't execute in either scenario. It appears the whole IF ELSE statement is not run on drag from the app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions