Hmm, this is not too bad. But it still is dependent on the layout.
BlCardLayout>>dropAccepted: anEvent
|wellPanelFlow droppedMorph localPosition |
wellPanelFlow := anEvent handler.
droppedMorph := anEvent contents asDragWell.
localPosition := wellPanelFlow globalPointToLocal: anEvent position.
wellPanelFlow hasSubmorphs ifFalse: [ wellPanelFlow addMorph:
droppedMorph ].
wellPanelFlow addMorph: droppedMorph asElementNumber: (self
indexForInserting: localPosition inList: wellPanelFlow submorphs)
BlCardLayout>>indexForInserting: aPoint inList: morphList
| cmp1 cmp2 cmp3 |
cmp1 := [:rect | aPoint x < rect right].
cmp2 := [:rect | aPoint y < rect bottom].
cmp3 := [:rect | aPoint y < rect top].
morphList keysAndValuesDo:
[:index :m | | box |
box := m fullBounds translateBy: m position.
"Check for inserting before current row"
(cmp3 value: box) ifTrue: [^index].
"Check for inserting before current
cell"
((cmp1 value: box) and: [cmp2 value: box]) ifTrue:
[^index]].
^morphList size + 1