'From etoys2.1 of 26 July 2007 [latest update: #1556] on 16 August 2007 at 10:06:36 pm'! "Change Set: picker-yo-sw Date: 17 August 2007 Author: Yoshiki Oshima, Scott Wallace TRAC 2831: Remove all uses of Sensor in color-picking, thus allowing event-replays of modal color picking to work. The approach is to replace all those references with references to the active hand, which then *does* play nicely with event recordings. A new inst var is added to the Hand to enable all needed distinctions between modal and nonmodal use to be enforced. "! Morph subclass: #HandMorph instanceVariableNames: 'mouseFocus keyboardFocus eventListeners mouseListeners keyboardListeners mouseClickState mouseOverHandler lastMouseEvent targetOffset damageRecorder cacheCanvas cachedCanvasHasHoles temporaryCursor temporaryCursorOffset hasChanged savedPatch userInitials lastEventBuffer genieGestureProcessor keyboardInterpreter modal' classVariableNames: 'CompositionWindowManager DoubleClickTime EventStats NewEventRules NormalCursor PasteBuffer ShowEvents' poolDictionaries: 'EventSensorConstants' category: 'Morphic-Kernel'! !ColorPickerMorph methodsFor: 'menu' stamp: 'yo 8/14/2007 18:32'! pickUpColorFor: aMorph "Show the eyedropper cursor, and modally track the mouse through a mouse-down and mouse-up cycle" | aHand localPt c | aHand _ aMorph ifNil: [self activeHand] ifNotNil: [aMorph activeHand]. aHand ifNil: [aHand _ self currentHand]. self addToWorld: aHand world near: (aMorph ifNil: [aHand world]) fullBoundsInWorld. self owner ifNil: [^ self]. aHand showTemporaryCursor: (ScriptingSystem formAtKey: #Eyedropper) hotSpotOffset: 6 negated @ 4 negated. "<<<< the form was changed a bit??" aHand modal: true. aHand mouseFocus: self. self updateContinuously: false. [aHand anyButtonPressed] whileFalse: [self trackColorUnderMouse. ActiveWorld doOneCycle]. self deleteAllBalloons. localPt _ aHand lastEvent cursorPoint - self topLeft. self inhibitDragging ifFalse: [(DragBox containsPoint: localPt) ifTrue: ["Click or drag the drag-dot means to anchor as a modeless picker" aHand modal: false. ^ self anchorAndRunModeless: aHand]]. (OpenFullBox containsPoint: localPt) ifTrue: [aHand modal: false. ^ self openPropertySheet]. (clickedTranslucency _ TransparentBox containsPoint: localPt) ifTrue: [selectedColor _ originalColor]. self updateContinuously: true. [aHand anyButtonPressed] whileTrue: [self updateTargetColorWith: self indicateColorUnderMouse. ActiveWorld doOneCycle]. aHand mouseFocus: nil. aHand modal: false. c _ self getColorFromKedamaWorldIfPossible: aHand cursorPoint. c ifNotNil: [selectedColor _ c]. aHand newMouseFocus: nil; showTemporaryCursor: nil; flushEvents. self delete! ! !ColorPickerMorph methodsFor: 'other' stamp: 'sw 4/30/2007 02:22'! indicateColorUnderMouse "Track the mouse with the special eyedropper cursor, and accept whatever color is under the mouse as the currently-chosen color; reflect that choice in the feedback box, and return that color." | pt | self pickColorAt: (pt _ ActiveHand cursorPoint). isModal ifTrue: [self activeHand position: pt. self world displayWorldSafely; runStepMethods]. ^ selectedColor ! ! !ColorPickerMorph methodsFor: 'other' stamp: 'sw 4/30/2007 02:24'! trackColorUnderMouse "Track the mouse with the special eyedropper cursor, and accept whatever color is under the mouse as the currently-chosen color; reflect that choice in the feedback box, and return that color." | pt | selectedColor _ originalColor. self trackColorAt: (pt _ self activeHand cursorPoint). isModal ifTrue: [self activeHand position: pt. self world displayWorldSafely; runStepMethods. self modalBalloonHelpAtPoint: pt]. ^ selectedColor ! ! !HandMorph methodsFor: 'accessing' stamp: 'yo 8/14/2007 17:39'! modal ^ modal ! ! !HandMorph methodsFor: 'accessing' stamp: 'yo 8/14/2007 17:39'! modal: aBoolean modal _ aBoolean. ! ! !HandMorph methodsFor: 'focus handling' stamp: 'yo 8/14/2007 18:14'! newMouseFocus: aMorphOrNil "Make the given morph the new mouse focus, canceling the previous mouse focus if any. If the argument is nil, the current mouse focus is cancelled." modal == true ifTrue: [^ self]. self mouseFocus: aMorphOrNil. ! !