[Pharo-project] suspicion update: method in MorphExtension

csrabak at bol.com.br csrabak at bol.com.br
Sun May 1 22:36:33 CEST 2011


Stef,

Em 01/05/2011 16:20, Stéphane Ducasse < stephane.ducasse at inria.fr > escreveu:
> Hi guys
>  I have a problem with a PluggableButtonMorph and I end up in this
>  MorpExtension>>update: aParameter

It seems to me it has more than what you suspect. . .

There are variables  called "getLabelSelector, getStateSelector and getColorSelector" or are "self" missing there?

All these tests with if<something> are also very _not_ OO :-|

Also, I think my low understanding of Morph in general may be skewing my reasoning, but it seems to me that this method would get better if some knowledgeable person could comment the code!

my 0.01999999

> 
>  |state|
>  aParameter  ifNil: [^self].
>  getLabelSelector ifNotNil: [
>  aParameter == getLabelSelector ifTrue: [
>  (self labelMorph respondsTo: #font)
>  ifTrue: [self label: (model perform: getLabelSelector) font: self labelMorph font]
>  ifFalse: [self label: (model perform: getLabelSelector)]]].
>  state := self getModelState.
>  (state ~= (self valueOfProperty: #lastState) or: [
>  getStateSelector isNil and: [aParameter == #onOffColor]])
>  ifTrue: [self color: self colorToUse.
>  self setProperty: #lastState toValue: state].
>  aParameter == getEnabledSelector ifTrue: [^self enabled: (model perform: getEnabledSelector)].
>  getColorSelector ifNotNil: [ | cc |
>  color = (cc := model perform: getColorSelector) 
>  ifFalse: [
>  color := cc.
>  self onColor: color offColor: color.
>  self changed ]].
> 
> To me it looks suspicious  that MorphExtension does that for all the
> morph....
>

--
Cesar Rabak



More information about the Pharo-project mailing list