I will try to clean a bit 
But this "SimpleButtonMorph" is not so simple

Now by redefining 

SimpleSwitchMorph>>mouseMove: evt

                ^ self

I addressed the bug. But all the code tells me that this is too complex. 

Ben I would like to pair program with you to define a B










Here is a list of things I saw and found not good.  

mouseDownMilleseconds is not used….

IconicButton>>interactSelector

         ^ #interact

IconicButton>>update: aSelector
        
        aSelector = self interactSelector
                ifTrue: [ ^ self doButtonAction ].
                
        super update: aSelector




SimpleButtonMorph>>label

        | s |
        s := ''.
        self allMorphsDo: [:m | (m isKindOf: StringMorph) ifTrue: [s := m 
contents]].
        ^ s

and 

SimpleButtonMorph>>label: aString font: aFont

        label ifNotNil: [label delete].
        label := StringMorph contents: aString font: (aFont ifNil: 
[StandardFonts buttonFont]).
        self extent: (label width + 6) @ (label height + 6).
        label position: self center - (label extent // 2).
        self addMorph: label.
        label lock


SimpleButtonMorph>>actionSelector: aSymbolOrString

        (nil = aSymbolOrString or:
         ['nil' = aSymbolOrString or:
         [aSymbolOrString isEmpty]])
                ifTrue: [^ actionSelector := nil].

        actionSelector := aSymbolOrString asSymbol.

berk!



SimpleButtonMorph>>arguments: aCollection

        arguments := aCollection asArray copy.

we copy here and there.

SimpleSwitchMorph>>doButtonAction
        "Perform the action of this button. The last argument of the message 
sent to the target is the new state of this switch."

        | newState |
        (target notNil and: [actionSelector notNil]) 
                ifTrue: 
                        [newState := color = onColor.
                        target perform: actionSelector
                                withArguments: (arguments copyWith: newState)]

Reply via email to