'From Cuis 5.0 [latest update: #4782] on 21 August 2021 at 2:03:13 pm'!

!SystemWindow methodsFor: '*MorphZooming-events' stamp: 'jmv 8/21/2021 14:00:18'!
handlesMouseScroll: aMouseScrollEvent
	"Answer true if we want mouse scroll events."
	
	aMouseScrollEvent controlKeyPressed | aMouseScrollEvent rawMacOptionKeyPressed ifFalse: [ 
		"D: Transcript cr; show: 'SW scroll no control key'.
		Transcript cr; show: aMouseScrollEvent buttons."
		^ super handlesMouseScroll: aMouseScrollEvent ].
	^ Preferences controlVerticalScrollScalesSystemWindow! !

!SystemWindow methodsFor: '*MorphZooming-events' stamp: 'jmv 8/21/2021 14:00:21'!
mouseScroll: aMouseScrollEvent localPosition: localEventPosition
	"Handle a mouse scroll event."

	| scaleFactor newScale |
	aMouseScrollEvent controlKeyPressed | aMouseScrollEvent rawMacOptionKeyPressed ifFalse: [ ^ self ].
	scaleFactor _ aMouseScrollEvent direction
		caseOf: {
			[ #up ] -> [ 1.05 ].
			[ #down ] -> [ `1 / 1.05` ].
			[ #left ] -> [ ^ self ].
			[ #right ] -> [ ^ self ] }.
	newScale _ self scale * scaleFactor min: 5 max: 0.5.
	(newScale - 1) abs < 0.01
		ifTrue: [ newScale _ 1 ].
	self scale: (newScale)! !

