[FIX] [ENH] TargetSighter-wiz (followup on Targetoffset ...)

Peace Jerome peace_the_dreamer at yahoo.com
Tue Jul 20 20:12:57 UTC 2004


How do you set the target on a slider or a button or a
...

 What should the Story for targets of sliders and
buttons be? For the fix I have use the modified story
for embed morph. I can also imagine a story that says:

'to aquire a target for the button you drag the james
bond crosshair handle from the halo of the slider over
the object to be targeted and click the mouse. a menu
of object under the crosshair is given.
Select from the menu to aquire a target. Click
elsewhere to dismiss the menu with target unchanged.'

The following change set allows sliders to be set by
either story. It fixes the bugs mentioned in
Target Offset needs a hand.  Please read that bug
report and suggested fix for important information.


>From Squeak3.7beta of ''1 April 2004'' [latest update:
#5967] on 20 July 2004 at 1:08:42 pm'!
"Change Set:		TargetSighter-wiz
Date:			20 July 2004
Author:			Jerome Peace (wiz)


Adds a James Bond Gunsight cursor to the available
cursors.  Meant to be used to help aquire targets for
buttons and sliders and contextual references for
workspaces.

Modifies menu for slider to use said cursor to select
targets.

For the purposes of evaluation menu includes both
setTarget and sightTarget.

Set target is conservative and offers exactly the menu
of objects as embed into does.

Sight target returns a menu of every morph it can
think of thats contained by the owner of the slider.

What is the best selection of morphs to target?
Anyone knowledgable in these matters is invited to
improve the selection. I've guessed the best I could
with my limited knowledge.

attached are both gzipped and plain text change sets.

Yours in Service,   Jerome Peace

 


		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
--0-1947423069-1090354377=:18856
Content-Type: application/x-gzip; name="TargetSighter-wiz.7.cs.gz"
Content-Transfer-Encoding: base64
Content-Description: TargetSighter-wiz.7.cs.gz
Content-Disposition: attachment; filename="TargetSighter-wiz.7.cs.gz"

H4sIAAAAAAAAB+1a3XPbNhJ/1oP+B8R5UNKrFVt2Eoc31zt/pK3bOM5ETnNz
adKBSEhCRQIMQNpRp3/8/XZBUJQt59Km7dNlEhFYLnaB/V4wg6+dLcT4fa3k
Ym/4eKIqKexUDAa74rB0OhejnZ39wUC8yWWlfCXqMsMg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P4jWI1QNFn4gVRamtinKmKp82TYqJRcYoM0g61icNxXWCop01Xn3Dh
h39eQa0UI4+WPL+K55k5W5cAzuUl5wttfmZeprI0oU+GUZh07dKexynGa1J4
+6RTHMej1YbWkYimOq/4cgsVWcFy4u/JhnranD5MmnMz5peJuCJ351WFrOZi
igTVVNpy4pHn02PLj7E29LiQeMBAJYoAlMw5JbnUUjs8c0odtyNCVx9K8LOI
I7kRsAtK1iiqMg0a2BZqzBnnEcclBUpwXTqb0idvKIQulpCvULUA0793FX4o
4gGKdF/RV94mmWa0+RJeFEyCR0/DRyR/DkEygNJHO6EBkpwjSLP4EoQGQhVl
tTyeq3QhFGKte8rzldEz8Lk9k1U6j5Pqa9pt0k6/R9NMH3uP4J4oA2S6YB5O
FfaSN8gjlcSnnh5OOG40AI4p7ZCJn5oOZFyn84u5DHGG/sMEE9WNx582X+th
TVPe/WrASb6FbRyv1qzINCNwPp92pojVnem4nniOoYBfodfC8bTvCE57Jhyf
5+45XS8iAL2vyXHCt3P/H+Us3XoFXLsKtmBFp/0C+WABy9Nmarcn0kNjsCCw
C2+7nzuv3WvweziB4crWbze2E2+02eC27XQ6CEMOz0hbaBV8FT5QJv0zuVAI
0y4LX0MVG2EO73Ey9/SfPSwbMvrf/gmqHgoP7GOdMmhIRP8L/LtP7xAjAAA=


--0-1947423069-1090354377=:18856
Content-Type: text/plain; name="TargetSighter-wiz.7.cs"
Content-Description: TargetSighter-wiz.7.cs
Content-Disposition: inline; filename="TargetSighter-wiz.7.cs"

'From Squeak3.7beta of ''1 April 2004'' [latest update: #5967] on 20 July 2004 at 1:08:42 pm'!
"Change Set:		TargetSighter-wiz
Date:			20 July 2004
Author:			Jerome Peace (wiz)


Adds a James Bond Gunsight cursor to the available cursors.  Meant to be used to help aquire targets for buttons and sliders and contextual references for workspaces.

Modifies menu for slider to use said cursor to select targets.

For the purposes of evaluation menu includes both setTarget and sightTarget.

Set target is conservative and offers exactly the menu of objects as embed into does.

Sight target returns a menu of every morph it can think of thats contained by the owner of the slider.

What is the best selection of morphs to target?
Anyone knowledgable in these matters is invited to improve the selection. I've guessed the best I could with my limited knowledge.

 "!

Form subclass: #Cursor
	instanceVariableNames: ''
	classVariableNames: 'BlankCursor BottomLeftCursor BottomRightCursor CornerCursor CrossHairCursor CurrentCursor DownCursor MarkerCursor MenuCursor MoveCursor NormalCursor OriginCursor ReadCursor ResizeLeftCursor ResizeTopCursor ResizeTopLeftCursor ResizeTopRightCursor RightArrowCursor SquareCursor TopLeftCursor TopRightCursor UpCursor WaitCursor WebLinkCursor WriteCursor XeqCursor TargetCursor '
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!

!Collection methodsFor: '*objectMenu' stamp: 'wiz 7/20/2004 13:06'!
asKnownNameMenu
	"Return a menu to select an element of the collection.  
	Menu uses the knownName or class name as only description of  
	element."
	| menu |
	menu := CustomMenu new.
	self
		do: [:m | menu
				add: (m knownName
						ifNil: [m class name asString])
				action: m].
	^ menu! !


!Cursor class methodsFor: 'class initialization' stamp: 'wiz 7/19/2004 23:20'!
initTarget
	TargetCursor := Cursor
				extent: 16 @ 16
				fromArray: #(2032 2184 4228 8322 16833 16513 16513 18569 32639 18569 16513 16513 8642 4228 2184 2032)
				offset: -8 @ -8! !

!Cursor class methodsFor: 'class initialization' stamp: 'wiz 7/19/2004 22:59'!
initialize
	"Create all the standard cursors..."
	self initOrigin.
	self initRightArrow.
	self initMenu.
	self initCorner.
	self initRead.
	self initWrite.
	self initWait.
	BlankCursor := Cursor new.
	self initXeq.
	self initSquare.
	self initNormalWithMask.
	self initCrossHair.
	self initMarker.
	self initUp.
	self initDown.
	self initMove.
	self initBottomLeft.
	self initBottomRight.
	self initResizeLeft.
	self initResizeTop.
	self initResizeTopLeft.
	self initResizeTopRight.
	self initTopLeft.
	self initTopRight.
	self initTarget.
	self makeCursorsWithMask! !

!Cursor class methodsFor: 'constants' stamp: 'wiz 7/19/2004 23:34'!
target
	"Answer the instance of me that is the shape of a gunsight."
	"Cursor target show"
	^ TargetCursor! !


!CustomMenu methodsFor: 'invocation' stamp: 'wiz 7/20/2004 12:18'!
startUp: initialSelection withCaption: caption at: aPoint 
	"Build and invoke this menu with the given initial selection and caption. 
	Answer the selection associated with the menu item chosen by the user 
	or nil if none is chosen."
	self build.
	initialSelection notNil
		ifTrue: [self preSelect: initialSelection].
	^ super startUpWithCaption: caption at: aPoint! !

!CustomMenu methodsFor: 'invocation' stamp: 'wiz 7/20/2004 12:20'!
startUpWithCaption: caption at: aPoint 
	"Build and invoke this menu with no initial selection. Answer the  
	selection associated with the menu item chosen by the user or nil if  
	none is chosen; use the provided caption"
	^ self startUp: nil withCaption: caption at: aPoint! !


!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/17/2004 22:17'!
potentialTargets
	"Return the potential targets for the receiver.
	This is derived from Morph>>potentialEmbeddingTargets."
	owner ifNil:[^#()].
	^owner morphsAt: self referencePosition behind: self unlocked: true not! !

!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/20/2004 02:46'!
potentialTargetsAt: aPoint 
	"Return the potential targets for the receiver.  
	This is derived from Morph>>potentialEmbeddingTargets."
	owner
		ifNil: [^ #()].
	^ owner
		morphsAt: aPoint
		! !

!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/20/2004 13:06'!
sightTargets: event 
	"Return the potential targets for the receiver.  
	This is derived from Morph>>potentialEmbeddingTargets."
	| bullseye |
	owner
		ifNil: [^ #()].
	bullseye := Point fromUserWithCursor: Cursor target.
	self targetFromMenu: (self potentialTargetsAt: bullseye) asKnownNameMenu popupAt: bullseye! !

!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/20/2004 01:25'!
targetFromMenu: aMenu 
	"Some other morph become target of the receiver"
	| newTarget |
	
	newTarget := aMenu startUpWithCaption: self externalName , ' targets...'.
	newTarget
		ifNil: [^ self].
	self target: newTarget! !

!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/20/2004 12:22'!
targetFromMenu: aMenu popupAt: aPoint 
	"Some other morph become target of the receiver"
	| newTarget |
	newTarget := aMenu startUpWithCaption: self externalName , ' targets... '
	at: aPoint .
	"self halt ."
	newTarget
		ifNil: [^ self].
	self target: newTarget! !

!Morph methodsFor: 'meta-actions' stamp: 'wiz 7/17/2004 23:27'!
targetWith: evt
	"Some other morph become target of the receiver"
	|  menu newTarget |
	menu _ CustomMenu new.
	self potentialTargets  do: [:m | 
		menu add: (m knownName ifNil:[m class name asString]) action: m].
	newTarget _ menu startUpWithCaption: ( self externalName, ' targets...').
	newTarget ifNil:[^self].
	self target: newTarget.! !


!Point class methodsFor: 'instance creation' stamp: 'wiz 7/20/2004 02:25'!
fromUserWithCursor: aCursor
	Sensor waitNoButton.
	 aCursor show.
	Sensor waitButton.
	Cursor normal show.
	^ Sensor cursorPoint"Point fromUser"! !


!SimpleSliderMorph methodsFor: 'menu' stamp: 'wiz 7/20/2004 01:48'!
addCustomMenuItems: aCustomMenu hand: aHandMorph 
	super addCustomMenuItems: aCustomMenu hand: aHandMorph.
	aCustomMenu addLine.
	aCustomMenu add: 'set action selector' translated action: #setActionSelector.
	aCustomMenu add: 'change arguments' translated action: #setArguments.
	aCustomMenu add: 'set minimum value' translated action: #setMinVal.
	aCustomMenu add: 'set maximum value' translated action: #setMaxVal.
	aCustomMenu addUpdating: #descendingString action: #toggleDescending.
	aCustomMenu addUpdating: #truncateString action: #toggleTruncate.
	aCustomMenu add: 'set target' translated action: #targetWith:.
	aCustomMenu add: 'sight target' translated action: #sightTargets:.
	target
		ifNotNil: [aCustomMenu add: 'clear target' translated action: #clearTarget]! !

Cursor initialize!
Form subclass: #Cursor
	instanceVariableNames: ''
	classVariableNames: 'BlankCursor BottomLeftCursor BottomRightCursor CornerCursor CrossHairCursor CurrentCursor DownCursor MarkerCursor MenuCursor MoveCursor NormalCursor OriginCursor ReadCursor ResizeLeftCursor ResizeTopCursor ResizeTopLeftCursor ResizeTopRightCursor RightArrowCursor SquareCursor TargetCursor TopLeftCursor TopRightCursor UpCursor WaitCursor WebLinkCursor WriteCursor XeqCursor'
	poolDictionaries: ''
	category: 'Graphics-Display Objects'!

!Collection reorganize!
('accessing' anyOne atRandom capacity size)
('adapting' adaptToCollection:andSend: adaptToNumber:andSend: adaptToPoint:andSend: adaptToString:andSend:)
('adding' add: add:withOccurrences: addAll: addIfNotPresent:)
('arithmetic' * + - / // \\ raisedTo:)
('comparing' hash)
('converting' asArray asBag asByteArray asCharacterSet asIdentitySet asIdentitySkipList asOrderedCollection asSet asSkipList asSkipList: asSortedArray asSortedCollection asSortedCollection: topologicallySortedUsing:)
('copying' , copyWith: copyWithDependent: copyWithout: copyWithoutAll:)
('enumerating' allSatisfy: anySatisfy: associationsDo: collect: collect:thenSelect: count: detect: detect:ifNone: detectMax: detectMin: detectSum: difference: do: do:separatedBy: do:without: groupBy:having: inject:into: intersection: noneSatisfy: reject: select: select:thenCollect: union:)
('filter streaming' contents flattenOnStream: write:)
('math functions' abs arcCos arcSin arcTan average ceiling cos degreeCos degreeSin exp floor ln log max median min negated range reciprocal rounded sign sin sqrt squared sum tan truncated)
('printing' printElementsOn: printNameOn: printOn: storeOn:)
('private' emptyCheck errorEmptyCollection errorNoMatch errorNotFound: errorNotKeyed toBraceStack:)
('removing' remove: remove:ifAbsent: removeAll: removeAllFoundIn: removeAllSuchThat:)
('testing' identityIncludes: ifEmpty: ifEmpty:ifNotEmpty: ifNotEmpty: ifNotEmpty:ifEmpty: includes: includesAllOf: includesAnyOf: includesSubstringAnywhere: isCollection isEmpty isEmptyOrNil isSequenceable isZero notEmpty occurrencesOf:)
('*packageinfo-base' gather:)
('*objectMenu' asKnownNameMenu)
('*connectors-truncation and round-off' roundTo:)
!

"Postscript:
Make hard to see tan literals be orange."

DialectStream initialize.
!


More information about the Squeak-dev mailing list