Augh...

Bob Arning arning at charm.net
Mon Oct 1 02:55:27 UTC 2001


On Mon, 1 Oct 2001 19:33:19 -0500 Daniel Joyce <daniel.a.joyce at att.net> wrote:
>	What class is used by the system to play sounds when morphs are 
>added/removed?
>
>	I've tried looking in Morph, but the class is a mess.

Well, let's see...

Removing a morph means, I guess, clicking on the pink handle which has balloon help saying 'remove from screen'. So I type 'remove from screen' in a workspace and press ctrl-e. Up pops a browser with a single method containing that string. That method strongly suggests that I would be interesed in a method #mouseDownInDimissHandle:with:, so I look at implementers of that and there is one in HaloMorph --

mouseDownInDimissHandle: evt with: dismissHandle
	...
	Preferences soundsEnabled ifTrue: [TrashCanMorph playMouseEnterSound].
	...

Well, this is what happens on mouse down, what happens on mouse up? Senders of #mouseDownInDimissHandle:with: reveals (also from HaloMorph) --

addDismissHandle: handleSpec
	| dismissHandle |
	dismissHandle _ self addHandle: handleSpec
		on: #mouseDown send: #mouseDownInDimissHandle:with: to: self.
	dismissHandle on: #mouseUp send: #maybeDismiss:with: to: self.
	dismissHandle on: #mouseDown send: #setDismissColor:with: to: self.
	dismissHandle on: #mouseMove send: #setDismissColor:with: to: self.

So, I wonder about #maybeDismiss:with: and that leads me to --

maybeDismiss: evt with: dismissHandle
	...
			target dismissViaHalo
	...

And thence to --

dismissViaHalo
	"The user has clicked in the delete halo-handle.  This provides a hook in case some concomitant action should be taken, or if the paticular morph is not one which should be put in the trash can, for example."

	TrashCanMorph moveToTrash: self

and on to --

moveToTrash: aMorph
	Preferences soundsEnabled ifTrue:
		[Preferences preserveTrash 
			ifFalse:
				[self playSoundNamed: 'scratch']
			ifTrue:
				[self playDeleteSound]].
	...

leading either to --

playDeleteSound
	"TrashCanMorph playDeleteSound"

	| snd |
	Smalltalk at: #SampledSound ifPresent: [:sampledSound |
		snd _ sampledSound
			samples: self samplesForDelete
			samplingRate: 22050.
		snd play].

or --

playSoundNamed: soundName
	"Play the sound with the given name. Do nothing if this image lacks sound playing facilities."

	Smalltalk at: #SampledSound ifPresent: [:sampledSound |
		sampledSound playSoundNamed: soundName asString].

so I would think SampledSound a likely answer to your question.

Cheers,
Bob




More information about the Squeak-dev mailing list