Drag & drop

23
Destination Finale 11

Transcript of Drag & drop

Page 1: Drag & drop

Destination Finale 11

Page 2: Drag & drop

Stéphane SudreGlisseur-déposeur

Page 3: Drag & drop

Démo

Page 4: Drag & drop

Sélection Simple

Page 5: Drag & drop
Page 6: Drag & drop
Page 7: Drag & drop

Drop autorisé

Page 8: Drag & drop

Sélection Multiple

Page 9: Drag & drop
Page 10: Drag & drop
Page 11: Drag & drop
Page 12: Drag & drop
Page 13: Drag & drop
Page 14: Drag & drop
Page 15: Drag & drop
Page 16: Drag & drop

Sélection continue

Interdire juste au-dessus et en dessous de la sélection

Page 17: Drag & drop

Sélection discontinue

Interdire en dessous de chaque élément de la sélection

Page 18: Drag & drop

Sélection continue ?

NSIndexSet

{ 1 , 3 , 4 } { 3 , 4 } { 0 , 2 }

nombre = dernier - premier + 1 ?

Page 19: Drag & drop

@implementation NSIndexSet (Analysis)

- (BOOL)containsOnlyOneRange{

NSUInteger tCount=[self count];

if (tCount>0){

NSUInteger tFirstIndex=[self firstIndex]; NSUInteger tLastIndex=[self lastIndex];

return ((tLastIndex-tFirstIndex+1)==tCount);}

return NO;

}

@end

Page 20: Drag & drop

if ([_internalDragData containsOnlyOneRange]==YES){

NSUInteger tFirstIndex=[_internalDragData firstIndex];NSUInteger tLastIndex=[_internalDragData lastIndex];

if (destRow>=tFirstIndex && destRow<=(tLastIndex+1))

return NSDragOperationNone;}else{

if ([_internalDragData containsIndex:(destRow-1)]==YES)return NSDragOperationNone;

} return NSDragOperationMove;

Page 21: Drag & drop

Démo

Page 22: Drag & drop

Références

Sample Code

s.sudre.free.fr/Stuff/CocoaHeads/Drag&DropSampleCode.zip

Page 23: Drag & drop

Q A&