[FIX] Extinguish mac-option key misuse

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Mon Sep 27 08:08:38 UTC 1999


>From the preamble: 

Replace the non-portable use of macOptionKeyPressed with
yellowButtonPressed (this makes the personal desktop menu accessable for
non-Mac users). Document what red, yellow, and blue buttons means.

  /bert

Content-Type: TEXT/PLAIN; charset=US-ASCII; name="MacOption-bf.22Sep347pm.cs"
Content-ID: <Pine.LNX.3.96.990927100838.31728G at balloon.cs.uni-magdeburg.de>
Content-Description: 

'From Squeak 2.5 of August 6, 1999 on 22 September 1999 at 3:47:35 pm'!
"Change Set:		x-option-bf
Date:			22 September 1999
Author:			Bert Freudenberg

Replace the non-portable use of macOptionKeyPressed with yellowButtonPressed (this makes the personal desktop menu accessable for non-Mac users). Document what red, yellow, and blue buttons means."!


!HandMorph methodsFor: 'world menu commands' stamp: 'bf 9/22/1999 12:26'!
invokeMetaMenu: evt
	"Invoke the meta menu. If the hand is over the background, the world menu is presented. If it is over a morph, a menu of operations for that morph is presented. Each menu entry contains a string to be presented in the menu and a selector. If the selector takes an argument, the mouse-down event that invoked the menu is passed as an argument. This lets the command know which hand invoked it in order to do things like attaching the result of the command to that hand.

If the hand is over the background and the shift key is pressed, the find-window menu is immediately put up.

If the hand is over the background and the 'mac-option-key' is pressed, an alternate menu, which individual users are encouraged to personalize, is put up -- see HandMorph.optionClickOnDesktopWithEvent:"

	| menu |
	Preferences noviceMode ifTrue: [^ self].

	"if carrying morphs, just drop them"
	self hasSubmorphs ifTrue: [^ self dropMorphsEvent: evt].

	targetOffset _ menuTargetOffset _ self position.
	argument _ self argumentOrNil.
	argument == nil
		ifTrue:
			[Utilities bringFlapsToFront.
			evt yellowButtonPressed
				ifTrue: [^ self optionClickOnDesktopWithEvent: evt].

			evt shiftPressed
				ifFalse:
					["put put screen menu"
					menu _ self buildWorldMenu.
					menu addTitle: 'World']
				ifTrue:
					[^ self findWindow]]
		ifFalse:
			[menu _ self buildMorphMenuFor: argument.
			menu addTitle: argument class name].
	self invokeMenu: menu event: evt.
! !


!InputSensor methodsFor: 'modifier keys' stamp: 'bf 9/22/1999 15:47'!
macOptionKeyPressed
	"Answer whether the option key on the Macintosh keyboard is being held down. Macintosh specific."

	Preferences macOptionKeyAllowed ifFalse: [self notify: 'Portability note:
InputSensor>>macOptionKeyPressed is not portable.
Please use InputSensor>>yellowButtonPressed instead!!'].
	^ self primMouseButtons anyMask: 32! !

!InputSensor methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:59'!
blueButtonPressed
	"Answer whether only the blue mouse button is being pressed. This is the third mouse button or cmd+click on the Mac."

	^self buttons = 1! !

!InputSensor methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:43'!
redButtonPressed
	"Answer true if the red mouse button is being pressed. This is the first mouse button."

	^self buttons = 4! !

!InputSensor methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:43'!
yellowButtonPressed
	"Answer whether only the yellow mouse button is being pressed. This is the second mouse button or option+click on the Mac."

	^self buttons = 2! !


!MorphicEvent methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:58'!
blueButtonPressed
	"Answer true if the blue mouse button is being pressed. This is the third mouse button or cmd+click on the Mac."

	^ buttons anyMask: 1! !

!MorphicEvent methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:41'!
redButtonPressed
	"Answer true if the red mouse button is being pressed. This is the first mouse button."

	^ buttons anyMask: 4! !

!MorphicEvent methodsFor: 'mouse' stamp: 'bf 9/22/1999 12:42'!
yellowButtonPressed
	"Answer true if the yellow mouse button is being pressed. This is the second mouse button or option+click on the Mac."

	^ buttons anyMask: 2! !

!MorphicEvent methodsFor: 'keyboard' stamp: 'bf 9/22/1999 13:07'!
macOptionKeyPressed
	"Answer whether the option key on the Macintosh keyboard was being held down when this event occurred. Macintosh specific."

	Preferences macOptionKeyAllowed ifFalse: [self notify: 'Portability note:
MorphicEvent>>macOptionKeyPressed is not portable.
Please use MorphicEvent>>yellowButtonPressed instead!!'].
	^ buttons anyMask: 32! !


!SimpleHierarchicalListMorph methodsFor: 'events' stamp: 'bf 9/22/1999 12:26'!
mouseDown: event onItem: aMorph

	| oldState |
	(aMorph inToggleArea: event) ifTrue: [
		"self setSelectedMorph: aMorph."
		event yellowButtonPressed ifTrue: [
			oldState _ aMorph isExpanded.
			scroller submorphs copy do: [ :each |
				(each canExpand and: [each isExpanded = oldState]) ifTrue: [
					each toggleExpandedState
				].
			].
		] ifFalse: [
			aMorph toggleExpandedState.
		].
		self adjustSubmorphPositions.
		^self
	].
	event yellowButtonPressed ifTrue: [^ self yellowButtonActivity: event shiftPressed].
	model okToChange ifFalse: [^ self].  "No change if model is locked"
	((autoDeselect == nil or: [autoDeselect]) and: [aMorph == selectedMorph])
		ifTrue: [self setSelectedMorph: nil]
		ifFalse: [self setSelectedMorph: aMorph].
! !





More information about the Squeak-dev mailing list