autoRise (was Re: woohoo! It's my first squeak/morphic alpha code!)
Robert Withers
withers at vnet.net
Sun Jan 30 05:10:24 UTC 2000
I'm glad you like it. I can't take any credit for the idea; it comes
from Linux/XFree86. Let me say that I think the list is the best place
for this exchange because someone may take your additions and add their
own. I'm not worried about ownership issues; it's all of ours. So
it's not less than polite, but rather asynchronous pair programming.
Your fixes make a lot of sense. Thanks! I was wondering how to bring
this to all Morphic windows, but I'm not familiar enough with the
Classes yet. I especially like your #autoRiseOnMouseEntry and your
placement of the Register dictionary as a class var in WindowRaiser (we
could call it a Necromancer if you wish! :) ). I don't know what I was
thinking, putting it in the Smalltalk dictionary. Just hacking, you
know?
Could you post your changeset, please? I want to build on it. I'd
like to figure out how to install a start/stop menu item in the World
popup (or preferences). I believe this would require removing the event
registrations from the windows that are active
(#cancelAutoRiseOnMouseEntry) and setting a class side flag in
WindowRaiser to not install the events for new windows. Finally, have
#autoRiseOnMouseEntry and #cancelAutoRiseOnMouseEntry defer ot class
methods on the WindowRaiser for installation/deinstallation of the
events. I also found that I like a 50 millisecond delay or none at
all. It's more immediate.
Do we have a consolidated 'settings' window? Is it <preferences...>? I
would also like to be able to configure the delay time. The other
thing I was thinking of was a (sub)popup list of all windows in the
active world/project. Clicking on one would activate it (for when I
have 250 inspectors and browsers open!).
cheers,
Rob
PS. My cat does that all the time, too! 8-) He even sits on my
keyboard for attention, and that wreaks havoc. (now I'm covered for any
missppelled words ;)
Stan Heckman wrote:
>
> 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
--
--------------------------------------------------
Smalltalking by choice. Isn't it nice to have one!
More information about the Squeak-dev
mailing list
|