How to add preferences (was Re: [NOTBUG] HandMorph missing menu actions)

Rob Withers slosher2 at home.com
Tue Jul 18 07:16:28 UTC 2000


Ned Konz wrote:
> 
> Rob Withers wrote:
> 
> > Is there a way to add a preference without writing an extension method
> > in the Preferences class?  I would like to do the same kind of thing
> > with the WorldMenu and the OpenMenu as well.  Is there a way to
> > dynamically add a menu item to one of those menus without writing a
> > method in the HandMorph class?
> 
> My Preferences changes included a mod to doesNotUnderstand: that allows
> preferences or flags to be set or returned. But it was too forgiving, I think,
> in that it would allow a new flag to be defined. This version requires
> that the flag or parameter be already defined:
> 
> Preferences class>>doesNotUnderstand: aMessage
>         "Look up the message selector as a flag or parameter. Return it
>         (if no arguments), or set it (if 1 argument)"
>         | flagName isParameter isFlag |
>         aMessage arguments size > 1
>                 ifTrue: [^ super doesNotUnderstand: aMessage].
>         flagName _ aMessage selector asLegalSelector asSymbol.
>         isParameter _ Parameters includesKey: flagName.
>         isFlag _ FlagDictionary includesKey: flagName.
>         (isParameter not and: [isFlag not])
>                 ifTrue: [^ super doesNotUnderstand: aMessage].
>         ^ aMessage arguments isEmpty
>                 ifTrue: [isParameter
>                                 ifTrue: [self parameterAt: flagName]
>                                 ifFalse: [self valueOfFlag: flagName]]
>                 ifFalse: [isParameter
>                                 ifTrue: [self setParameter: flagName to: aMessage arguments first]
>                                 ifFalse: [self setPreference: flagName toValue: aMessage arguments first]]
> 
> Then you either use valueOfFlag:default: or setPreference:toValue: to set the
> preference.

Ok, this looks like the trick.

> Look at my enhancements to Preferences to see a further extension that notifies
> dependents of Preferences about changes.

Where might I find your enhancements to Preferences? (in the image
stupid! ;-)

thanks, Ned,
Rob

> --
> Ned Konz
> currently: Stanwood, WA
> email:     ned at bike-nomad.com
> homepage:  http://bike-nomad.com

-- 
--------------------------------------------------
Smalltalking by choice.  Isn't it nice to have one!





More information about the Squeak-dev mailing list