491 ]. |
491 ]. |
492 ! ! |
492 ! ! |
493 |
493 |
494 !UIPainterView methodsFor:'drag & drop'! |
494 !UIPainterView methodsFor:'drag & drop'! |
495 |
495 |
496 canDrop:something |
496 canDrop:aCollectionOfDropObjects |
497 "returns true if something can be dropped" |
497 "returns true if something can be dropped" |
498 |
498 |
499 (something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
499 (aCollectionOfDropObjects size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
500 ^ something first theObject isKindOf:UISpecification |
500 ^ aCollectionOfDropObjects first theObject isKindOf:UISpecification |
501 ]. |
501 ]. |
502 ^ false |
502 ^ false |
503 ! |
503 ! |
504 |
504 |
505 canPaste |
505 canPaste |
541 ^ prop spec class supportsSubComponents |
541 ^ prop spec class supportsSubComponents |
542 ]. |
542 ]. |
543 ^ aView specClass supportsSubComponents. |
543 ^ aView specClass supportsSubComponents. |
544 ! |
544 ! |
545 |
545 |
546 drop:anObjectOrCollection at:aPoint |
546 drop:aCollectionOfDropObjects at:aPoint |
547 |spec newSel oldSel dragOffset widg doit| |
547 |spec newSel oldSel dragOffset widg doit| |
548 |
548 |
549 doit := true. |
549 doit := true. |
550 self selection notNil ifTrue:[ |
550 self selection notNil ifTrue:[ |
551 oldSel := self singleSelection. |
551 oldSel := self singleSelection. |
552 |
552 |
553 "/ search selections hierarchy for a widget into which we can paste |
553 "/ search selections hierarchy for a widget into which we can paste |
554 widg := oldSel. |
554 widg := oldSel. |
555 [widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
555 [widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
556 widg notNil ifTrue:[ |
556 widg notNil ifTrue:[ |
557 widg := widg container |
557 widg := widg container |
558 ]. |
558 ]. |
559 ]. |
559 ]. |
560 |
560 |
561 oldSel := nil. |
561 oldSel := nil. |
562 self setSelection:widg withRedraw:true. |
562 self setSelection:widg withRedraw:true. |
563 ]. |
563 ]. |
564 spec := (anObjectOrCollection at:1) theObject. |
564 spec := (aCollectionOfDropObjects at:1) theObject. |
565 doit ifTrue:[ |
565 doit ifTrue:[ |
566 dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
566 dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
567 newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
567 newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
568 |
568 |
569 self select:(oldSel ? newSel) |
569 self select:(oldSel ? newSel) |
570 ]. |
570 ]. |
571 |
571 |
572 "Modified: / 18.3.1999 / 18:29:43 / stefan" |
572 "Modified: / 18.3.1999 / 18:29:43 / stefan" |
573 "Modified: / 30.10.2001 / 14:02:35 / cg" |
573 "Modified: / 30.10.2001 / 14:02:35 / cg" |
574 ! ! |
574 ! ! |