Andreas Raab uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ul.246.mcz ==================== Summary ==================== Name: Morphic-ul.246 Author: ul Time: 23 November 2009, 2:58:55 am UUID: 2b77c9e7-a9d9-e840-a68e-c33ad6d4f837 Ancestors: Morphic-dtl.245 - fix: don't raise an error if the primitive can't open a stream for a dropped file (http://lists.squeakfoundation.org/pipermail/squeak-dev/2009-September/139207.html) - fix: MouseOverHandler >> #noticeMouseOver:event: sent #includes: to a possibly nil object. Fixed the same way the pharo guys did, but without splitting #processMouseOver: into a lot of small methods. Bug reports: http://bugs.squeak.org/view.php?id=2697 http://bugs.squeak.org/view.php?id=6186 http://bugs.squeak.org/view.php?id=7415 http://code.google.com/p/pharo/issues/detail?id=889 =============== Diff against Morphic-dtl.245 =============== Item was added: + ----- Method: MouseOverHandler>>initializeTrackedMorphs (in category 'initialize-release') ----- + initializeTrackedMorphs + + leftMorphs := OrderedCollection new. + overMorphs := WriteStream on: #(). + enteredMorphs := WriteStream on: #().! Item was changed: ----- Method: MouseOverHandler>>initialize (in category 'initialize-release') ----- initialize + + mouseOverMorphs := Array new. + self initializeTrackedMorphs! - mouseOverMorphs := #().! Item was changed: ----- Method: PasteUpMorph>>dropFiles: (in category 'event handling') ----- dropFiles: anEvent "Handle a number of dropped files from the OS. TODO: - use a more general mechanism for figuring out what to do with the file (perhaps even offering a choice from a menu) - remember the resource location or (when in browser) even the actual file handle " | numFiles stream handler | numFiles := anEvent contents. + 1 to: numFiles do: [ :i | + (stream := FileStream requestDropStream: i) ifNotNil: [ + handler := ExternalDropHandler lookupExternalDropHandler: stream. + [ handler ifNotNil: [handler handle: stream in: self dropEvent: anEvent ] ] + ensure: [ stream close ] ] ].! - 1 to: numFiles do: [:i | - stream := FileStream requestDropStream: i. - handler := ExternalDropHandler lookupExternalDropHandler: stream. - [handler ifNotNil: [handler handle: stream in: self dropEvent: anEvent]] - ensure: [stream close]].! Item was changed: ----- Method: MouseOverHandler>>noticeMouseOver:event: (in category 'event handling') ----- noticeMouseOver: aMorph event: anEvent "Remember that the mouse is currently over some morph" + + leftMorphs remove: aMorph ifAbsent: [ + enteredMorphs nextPut: aMorph ]. - (leftMorphs includes: aMorph) - ifTrue:[leftMorphs remove: aMorph] - ifFalse:[enteredMorphs nextPut: aMorph]. overMorphs nextPut: aMorph. ! Item was changed: ----- Method: MouseOverHandler>>processMouseOver: (in category 'event handling') ----- processMouseOver: anEvent "Re-establish the z-order for all morphs wrt the given event" | hand localEvt focus evt | hand := anEvent hand. leftMorphs := mouseOverMorphs asIdentitySet. "Assume some coherence for the number of objects in over list" overMorphs := WriteStream on: (Array new: leftMorphs size). enteredMorphs := WriteStream on: #(). "Now go looking for eventual mouse overs" hand handleEvent: anEvent asMouseOver. "Get out early if there's no change" + (leftMorphs isEmpty and: [ enteredMorphs position = 0 ]) + ifTrue: [ ^self initializeTrackedMorphs ]. - (leftMorphs isEmpty and: [enteredMorphs position = 0]) - ifTrue: [^leftMorphs := enteredMorphs := overMorphs := nil]. focus := hand mouseFocus. "Send #mouseLeave as appropriate" evt := anEvent asMouseLeave. "Keep the order of the left morphs by recreating it from the mouseOverMorphs" leftMorphs size > 1 ifTrue: [leftMorphs := mouseOverMorphs select: [:m | leftMorphs includes: m]]. + leftMorphs do: [ :m | + (m == focus or: [m hasOwner: focus]) + ifFalse: [ overMorphs nextPut: m ] + ifTrue: [ + localEvt := evt transformedBy: (m transformedFrom: hand). + m handleEvent: localEvt ] ]. + enteredMorphs ifNil: [ "inform: was called in handleEvent:" + ^self initializeTrackedMorphs ]. - leftMorphs do: - [:m | - (m == focus or: [m hasOwner: focus]) - ifTrue: - [localEvt := evt transformedBy: (m transformedFrom: hand). - m handleEvent: localEvt] - ifFalse: [overMorphs nextPut: m]]. "Send #mouseEnter as appropriate" evt := anEvent asMouseEnter. - enteredMorphs ifNil: - ["inform: was called in handleEvent:" - - ^leftMorphs := enteredMorphs := overMorphs := nil]. enteredMorphs := enteredMorphs contents. + enteredMorphs reverseDo: [ :m | + (m == focus or: [m hasOwner: focus]) ifTrue: [ + localEvt := evt transformedBy: (m transformedFrom: hand). + m handleEvent: localEvt ] ]. - enteredMorphs reverseDo: - [:m | - (m == focus or: [m hasOwner: focus]) - ifTrue: - [localEvt := evt transformedBy: (m transformedFrom: hand). - m handleEvent: localEvt]]. "And remember the over list" + overMorphs ifNotNil: [ + mouseOverMorphs := overMorphs contents ]. + self initializeTrackedMorphs! - overMorphs ifNil: - ["inform: was called in handleEvent:" - - ^leftMorphs := enteredMorphs := overMorphs := nil]. - mouseOverMorphs := overMorphs contents. - leftMorphs := enteredMorphs := overMorphs := nil! |
Free forum by Nabble | Edit this page |