[Pkg] The Trunk: Morphic-cmm.979.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon May 11 02:31:09 UTC 2015
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.979.mcz
==================== Summary ====================
Name: Morphic-cmm.979
Author: cmm
Time: 10 May 2015, 9:30:17.138 pm
UUID: 9fd42360-be4c-4997-88ea-88117e1e4573
Ancestors: Morphic-cmm.978
Give any Morph the ability to conditionally delete if it does not have keyboard focus and use it for the scratch pad because setting up a #keyboardFocusChange handler doesn't work or is not robust enough to ensure it remains discreet.
=============== Diff against Morphic-cmm.978 ===============
Item was added:
+ ----- Method: Morph>>deleteUnlessHasFocus (in category 'submorphs-add/remove') -----
+ deleteUnlessHasFocus
+ "Runs on a step timer because we cannot be guaranteed to get focus change events."
+ (ActiveHand keyboardFocus ~= self and: [ self isInWorld ]) ifTrue:
+ [ self
+ stopSteppingSelector: #deleteUnlessHasFocus ;
+ delete ]!
Item was changed:
----- Method: SearchBar>>activate:in: (in category 'accessing') -----
activate: event in: morph
+ self class useScratchPad
- UseScratchPad
ifTrue:
[ event hand keyboardFocus = self scratchPad ifFalse: [ originatingWidget := event hand keyboardFocus ].
self scratchPad selectAll; openInWorld.
+ self layoutScratchPad.
event hand newKeyboardFocus: self scratchPad ]
ifFalse:
[ self selection: (1 to: self searchTerm size).
event hand newKeyboardFocus: morph textMorph ]!
Item was added:
+ ----- Method: SearchBar>>layoutScratchPad (in category 'private') -----
+ layoutScratchPad
+ | pos width |
+ World mainDockingBars do:
+ [ : each | each searchBarMorph ifNotNil:
+ [ : searchBar | pos := searchBar bottomLeft.
+ width := searchBar width ] ].
+ width ifNil: [ width := 250. pos := World topRight - (width @ 5) ].
+ scratchPad
+ width: width ;
+ position: pos ;
+ startStepping: #deleteUnlessHasFocus at: Time millisecondClockValue arguments: nil stepTime: 3000!
Item was changed:
----- Method: SearchBar>>scratchPad (in category 'accessing') -----
scratchPad
^ scratchPad ifNil:
+ [ scratchPad := TextMorph new.
- [ | pos width |
- World mainDockingBars do:
- [ : each | each searchBarMorph ifNotNil:
- [ : searchBar | pos := searchBar bottomLeft. width:=searchBar width ] ].
- width ifNil: [ width:=250. pos := World topRight - (width @ 5) ].
- scratchPad := TextMorph new.
scratchPad
+ " on: #keyboardFocusChange send: #removeScratchPad to: self ;"
- on: #keyboardFocusChange send: #removeScratchPad to: self ;
on: #mouseLeave send: #removeScratchPad to: self ;
on: #keyStroke send: #handleScratchPadKey: to: self ;
backgroundColor: (BalloonMorph balloonColor alpha: 1.0) ;
- width: width ;
autoFit: true ;
wrapFlag: true ;
newContents: '--scratch area--' ;
yourself.
+ self layoutScratchPad.
- scratchPad position: pos.
Preferences menuAppearance3d ifTrue: [ scratchPad addDropShadow ].
scratchPad ]!
More information about the Packages
mailing list