woohoo! It's my first squeak/morphic alpha code!

Stan Heckman stan at stanheckman.com
Fri Jan 28 23:09:32 UTC 2000


Robert Withers <withers at vnet.net> writes:

This is very nice. I like it already. 

I modified it to work on all system windows, not just the browser. In
the process, I rearranged your code more than is probably polite. I'll
describe I did, so you can decide "Nah, I don't want any of those
changes in my code." :-)

First some really indefensible changes. There is a long history in
Smalltalk of storing useful Singletons in global variables, just as
you have done with WindowRaiserEventRegister. So really, I have no
business messing with this. But my personal biases are that this is
appropriate for the classes everyone will use, but less appropriate
for classes that only a few of us will use. So I prefer putting the
EventRegister in a class variable of class WindowRaiser, a class that
those of us who use this enhancement will have on our systems and
those who don't will not have. So I added a class variable named
#EventRegister to WindowRaiser.

    Object subclass: #WindowRaiser
        instanceVariableNames: 'view timer '
        classVariableNames: 'EventRegister '
        poolDictionaries: ''
        category: 'Slosher-Tools-Extensions'

Then I added class methods "initialize" and "eventRaiser" to
initialize and access this variable. This is also indefensible; there
is no reason that my explicit initialization is any better than your
lazy initialization. 

    initialize
        EventRegister := Dictionary new.
    eventRegister
        ^ EventRegister

Next I add an #autoRiseOnMouseEntry method to Morph. I wasn't sure
where best to put this; I've stuffed it into "event handling" for
now. This may be no more defensible than my previous
changes. I find my rewrite easier for me to read, but these things are 
vary from person to person, and you probably like your own version
better. In any case, you should recognize that this is exactly your
#openBrowserView:label: code, just rearranged a little.

!Morph methodsFor: 'event handling' stamp: 'sjh 1/28/2000 16:08'!
    autoRiseOnMouseEntry
	self 
	    on: #mouseEnter 
	    send: #value 
	    to: 
		[WindowRaiser eventRegister
		    at: self 
		    put: ((WindowRaiser newOn: self) waitFor: 500)].
	self 
	    on: #mouseLeave 
	    send: #value 
	    to: 
		[(WindowRaiser eventRegister
		    removeKey: self 
		    ifAbsent: [^ self]) stop]

Now any morph that receives the method "autoRiseOnMouseEntry" will
begin exhibiting your autorise behavior. Let's arrange to have this
message sent to all system windows when they are started up. We
change the openInWorld and openInWorld: messages of SystemWindow.

    !SystemWindow methodsFor: 'open/close' stamp: 'sjh 1/28/2000 16:10'!
    openInWorld
        self autoRiseOnMouseEntry.
        super openInWorld! !

    !SystemWindow methodsFor: 'open/close' stamp: 'sjh 1/28/2000 16:16'!
    openInWorld: aWorld
        "This msg and its callees result in the window being activeOnlyOnTop"
        self autoRiseOnMouseEntry.
        self bounds: (RealEstateAgent initialFrameFor: self).
        aWorld addMorph: self.
        self activate.
        aWorld startSteppingSubmorphsOf: self! !

Thats all I did. With these changes, all system windows (or at least
those I tested) exhibit your autorise behavior. Thanks again for your
useful change set; I'm already enjoying how much less clicking I have
to do this way. 

I hope it is popular with more squeakers than just the two of us. I
despair of it ever being popular with the majority; my coworkers think
my workstation is cursed because whenever they move the mouse "out of
the way", some window comes up from behind and obscures what they were
reading, sort of like a cat that wants attention so sits on the
newspaper you are reading. :-) Auto rise is an acquired taste.

I'm interested in any questions or comments you may have.

-- 
Stan





More information about the Squeak-dev mailing list