'From etoys2.1 of 26 July 2007 [latest update: #1513] on 30 July 2007 at 12:05:04 am'! "Change Set: selectionMorphIssues-sw Date: 8 August 2007 Author: Scott Wallace Assure halo is deleted from an object being deleted, taking care in case in the SelectionMorph case. Also fixes an occasional error condition encountered in extending the selection of a SelectionMorph."! !Morph methodsFor: '*green' stamp: 'sw 4/7/2007 01:17'! delete "Remove the receiver as a submorph of its owner and make its new owner be nil." | aWorld | aWorld := self world ifNil: [World]. "Terminate genie recognition focus" "I encountered a case where the hand was nil, so I put in a little protection - raa " " This happens when we are in an MVC project and open a morphic window. - BG " aWorld ifNotNil: [self disableSubmorphFocusForHand: self activeHand. self activeHand ifNotNilDo: [:h | h releaseKeyboardFocus: self. h releaseMouseFocus: self]]. self removeHalo. owner ifNotNil:[ self privateDelete. self player ifNotNilDo: [ :player | "Player must be notified" player noteDeletionOf: self fromWorld: aWorld]].! ! !SelectionMorph methodsFor: 'geometry' stamp: 'sw 5/17/2007 12:17'! extent: newExtent "Set the receiver's extent Extend or contract the receiver's selection to encompass morphs within the new extent." super extent: newExtent. self selectSubmorphsOf: (self pasteUpMorph ifNil: [^ self])! ! !SelectionMorph methodsFor: 'halo commands' stamp: 'sw 5/17/2007 11:56'! removeHalo "Remove the receiver's halo. Here we do nothing, because of the special relationship between the receiver and its halo"! ! !SelectionMorph methodsFor: 'private' stamp: 'sw 5/17/2007 12:06'! selectSubmorphsOf: aMorph "Given the receiver's current bounds, select submorphs of the indicated pasteup morph that fall entirely within those bounds. If nobody is within the bounds, delete the receiver." | newItems removals | newItems _ aMorph submorphs select: [:m | (bounds containsRect: m fullBounds) and: [m~~self and: [(m isKindOf: HaloMorph) not]]]. otherSelection ifNil: [^ selectedItems _ newItems]. removals _ newItems intersection: itemsAlreadySelected. otherSelection setSelectedItems: (itemsAlreadySelected copyWithoutAll: removals). selectedItems _ (newItems copyWithoutAll: removals). selectedItems ifEmpty: [self delete] ! !