objective c - mouseUp not firing in Cocoa? -
i'm trying implement drag&drop functionality in app , ran problem of mouseup event not firing. fires fine if click , release on view, if drag, mousedragged event fires , that's it.
by trying different things figured out problem in dragimage call, don't know how solve now.
here code:
-(void) mousedragged:(nsevent *)theevent { isdragging = yes; if ([selectedcellrowindex longvalue] >= 0) { nsimage *im = [[nsimage alloc]initwithcontentsoffile:@"/users/username/desktop/drag.png"]; nssize dragoffset = nsmakesize(0.0, 0.0); nspasteboard *pboard = [nspasteboard pasteboardwithname:nsdragpboard]; [pboard declaretypes:[nsarray arraywithobject:nstiffpboardtype] owner:self]; [pboard setdata:[im tiffrepresentation] fortype:nstiffpboardtype]; [self dragimage:im at:downpointrelativetotable offset:dragoffset event:theevent pasteboard:pboard source:self slideback:yes]; } }
does know problem can be?! thank you!
in code snippet you're getting nspasteboard
instance not copying data it. that's required, otherwise drag won't initiated - that's why you'll never mouseup:
event.
the docs dragimage:at:offset:event:pasteboard:source:slideback:
state
before invoking method, must place data transferred on pboard. this, drag pasteboard object (nsdragpboard), declare types of data, , put data on pasteboard.
Comments
Post a Comment