[squeak-dev] Dependencies on Cursor

Frank Shearar frank.shearar at gmail.com
Mon Jun 24 12:31:14 UTC 2013


Lots of code (174 senders) use something like:

    Cursor wait showWhile: ["stuff"]

That's great, and neat, and causes a dependency on the entire Graphics
package. I propose breaking this dependency by extending UIManager's
protocol. You would then write:

    UIManager default showCursor: #wait during: ["stuff"]

I use a Symbol to identify the cursor because that doesn't require
depending on any particular classes. Perhaps UIManager >>
#showCursor:during: can lay out the minimum expected set of labels
(whatever Cursor currently lists). Then MorphicUIManager and
MVCUIManager can implement this method in the existing way, with ^
Cursor foo showWhile: aBlock

One other change is needed, and that's to handle mistakes. So I propose

Cursor class >> #named: aSymbol
    ^ (self respondsTo: #named)
        ifTrue: [self perform: aSymbol]
        ifFalse: [self normal].

The reason for the icky reflection is to fit in with the existing way
cursors are used. I'd be happy to unroll the #perform: into a #caseOf:
mapping explicitly to the existing cursors.

Thoughts?

frank


More information about the Squeak-dev mailing list