[squeak-dev] Finding a UIManager
Frank Shearar
frank.shearar at gmail.com
Sat Dec 7 19:58:31 UTC 2013
On 7 December 2013 19:43, H. Hirzel <hannes.hirzel at gmail.com> wrote:
> On 12/7/13, Frank Shearar <frank.shearar at gmail.com> wrote:
>> At the moment, "UIManager default" delegates to Project current
>> uiManager, which looks like this:
>>
>> Project >> uiManager
>> "Answer the manager that provides user interface services for this
>> project "
>> ^ uiManager
>> ifNil: [uiManager := Smalltalk
>> at: #UIManager
>> ifPresent: [:mgr | uiManager := mgr getDefault]]
>>
>> I'm not sure why we do this. I guess it's to let different Projects
>> use their own UIManager. What I don't like is that this makes
>> ToolBuilder-Kernel depend on System (which depends on
>> ToolBuilder-Kernel). If I made UIManager default _not_ delegate to
>> Project, I could break this dependency. (ToolBuilder would then be
>> conceptually lower level than System.)
>>
>> For instance,
>>
>> UIManager class >> #default
>> ^ Default ifNil: [Default := self getDefault].
>
> How would #getDefault look like?
It already exists:
UIManager class >> getDefault
"Ensure that a more specific manager can always be made by subclassing
a tool builder and implementing a more specific way of reacting to
#isActiveManager. For example, a BobsUIManager can subclass
MorphicUIManager and (if enabled, say Preferences useBobsUI) will
be considered before the parent (generic MorphicUIManager)."
^ (self allSubclasses
detect: [:any | any isActiveManager
and: [any subclasses
noneSatisfy: [:sub | sub isActiveManager]]]
ifNone: [])
ifNotNilDo: [:mgrClass | mgrClass new]
frank
More information about the Squeak-dev
mailing list
|