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 ]! |
Can you name some other scenarious where this #deleteUnlessHasFocus is useful? Looks very specific and not useful in general. We should not blow up the Morph class more than needed. Maybe you could elaborate a little bit more on that feature.
You could subclass TextMorph for this special Scratch-Pad-Feature instead of extending the Morph class. Best, Marcel |
On Sun, May 10, 2015 at 11:02 PM, marcel.taeumel <[hidden email]> wrote:
> Can you name some other scenarious where this #deleteUnlessHasFocus is > useful? Looks very specific and not useful in general. Your "results" balloon of the SearchBar should use this too. Any morph anywhere that should go away when it loses focus. Handling #mouseLeave is not sufficient because the mouse is not guaranteed to have ever entered the bounds of the Morph. I use this concept in my Maui interfaces a lot -- hovering over a message invokes the message and presents output panel (with hand not inside its bounds), then I mouse away somewhere else but if I never entered the output, there is no mouseLeave event. A similar case are balloon help, which disappear on a timer. > We should not blow up > the Morph class more than needed. Agree, but I think this is useful in several cases and its just one method.. Best, Chris |
Free forum by Nabble | Edit this page |