Hello,
As I already indicated one week ago, UpdatingStringMorph is currently broken in trunk. If you do (UpdatingStringMorph on: Time selector: #now) openInWorld. you will see that the display is not consistently updated as it should via the #step method. This can be fixed by adding a #changed in StringMorph>>#contents: as follow: StringMorph>>#contents: newContents newContents isText ifTrue: [^ self initializeFromText: newContents]. contents = newContents ifTrue: [^ self "no substantive change"]. contents := newContents. self fitContents; changed Now maybe the #changed should be added to #fitContents itself. Stef |
We should make fitContens a bit smarter/ dumber. It should send changed even if extent is the same
UpdatingStringMorph>>fitContents | newExtent | newExtent := self measureContents. newExtent := ((newExtent x max: self minimumWidth) min: self maximumWidth) @ newExtent y. (self extent = newExtent) ifFalse: [self extent: newExtent. self changed] Best, Karl On Sun, Jan 5, 2020 at 6:06 PM Stéphane Rollandin <[hidden email]> wrote: Hello, |
I don't know the best solution, but I checked change history to see where
the problem originated. Prior to Morphic-mt.1512 of September 2019, UpdatingStringMorph implemented #contents: and the implementation sent #changed if the contents were changed. Now we have #contents: only in the superclass StringMorph, and it does not send #changed:. Perhaps we should again override #contents: in UpdatingStringMorph to detect the change? UpdatingStringMorph>>contents: newContents contents = newContents ifTrue: [super contents: newContents] ifFalse: [super contents: newContents. self changed] I note that the old version of UpdatingStringMorph>>contents: (method stamp aoy 2/17/2003) has this in its comment: "This is the original StringMorph implementation of #contents:, restored down in UpdatingStringMorph because a recent 'optimization' of the StringMorph version of this method broke UpdatingStringMorphs." So it looks like the 2003 version was a bit of a hack to work around some previous problem, and the 2019 version got rid of the hack but lost the #changed notification. Dave On Sun, Jan 05, 2020 at 06:19:48PM +0100, karl ramberg wrote: > We should make fitContens a bit smarter/ dumber. It should send changed > even if extent is the same > > UpdatingStringMorph>>fitContents > > | newExtent | > newExtent := self measureContents. > newExtent := ((newExtent x max: self minimumWidth) min: self maximumWidth) > @ newExtent y. > (self extent = newExtent) ifFalse: > [self extent: newExtent. > self changed] > > Best, > Karl > > On Sun, Jan 5, 2020 at 6:06 PM St??phane Rollandin <[hidden email]> > wrote: > > > Hello, > > > > As I already indicated one week ago, UpdatingStringMorph is currently > > broken in trunk. > > > > If you do > > > > (UpdatingStringMorph on: Time selector: #now) openInWorld. > > > > you will see that the display is not consistently updated as it should > > via the #step method. > > > > > > This can be fixed by adding a #changed in StringMorph>>#contents: as > > follow: > > > > > > StringMorph>>#contents: newContents > > > > newContents isText > > ifTrue: [^ self initializeFromText: newContents]. > > > > contents = newContents > > ifTrue: [^ self "no substantive change"]. > > > > contents := newContents. > > > > self fitContents; changed > > > > > > Now maybe the #changed should be added to #fitContents itself. > > > > Stef > > > > > |
Sorry for replying to myself, but history aside I think that the
approach of changing #fitContents as suggested by both Stef and Karl is probably best overall, because #fitContents is called whenever the contents change, and rarely otherwise. UpdatingStringMorph>>fitContents | newExtent | newExtent := self measureContents. newExtent := ((newExtent x max: self minimumWidth) min: self maximumWidth) @ newExtent y. self extent = newExtent ifFalse: [self extent: newExtent]. self changed. "contents have changed even if the extent remains the same" Dave On Sun, Jan 05, 2020 at 03:33:31PM -0500, David T. Lewis wrote: > I don't know the best solution, but I checked change history to see where > the problem originated. > > Prior to Morphic-mt.1512 of September 2019, UpdatingStringMorph > implemented #contents: and the implementation sent #changed if the > contents were changed. Now we have #contents: only in the superclass > StringMorph, and it does not send #changed:. > > Perhaps we should again override #contents: in UpdatingStringMorph > to detect the change? > > UpdatingStringMorph>>contents: newContents > contents = newContents > ifTrue: [super contents: newContents] > ifFalse: [super contents: newContents. > self changed] > > > I note that the old version of UpdatingStringMorph>>contents: (method stamp > aoy 2/17/2003) has this in its comment: > > "This is the original StringMorph implementation of #contents:, restored > down in UpdatingStringMorph because a recent 'optimization' of the > StringMorph version of this method broke UpdatingStringMorphs." > > So it looks like the 2003 version was a bit of a hack to work around some > previous problem, and the 2019 version got rid of the hack but lost the > #changed notification. > > Dave > > On Sun, Jan 05, 2020 at 06:19:48PM +0100, karl ramberg wrote: > > We should make fitContens a bit smarter/ dumber. It should send changed > > even if extent is the same > > > > UpdatingStringMorph>>fitContents > > > > | newExtent | > > newExtent := self measureContents. > > newExtent := ((newExtent x max: self minimumWidth) min: self maximumWidth) > > @ newExtent y. > > (self extent = newExtent) ifFalse: > > [self extent: newExtent. > > self changed] > > > > Best, > > Karl > > > > On Sun, Jan 5, 2020 at 6:06 PM St??phane Rollandin <[hidden email]> > > wrote: > > > > > Hello, > > > > > > As I already indicated one week ago, UpdatingStringMorph is currently > > > broken in trunk. > > > > > > If you do > > > > > > (UpdatingStringMorph on: Time selector: #now) openInWorld. > > > > > > you will see that the display is not consistently updated as it should > > > via the #step method. > > > > > > > > > This can be fixed by adding a #changed in StringMorph>>#contents: as > > > follow: > > > > > > > > > StringMorph>>#contents: newContents > > > > > > newContents isText > > > ifTrue: [^ self initializeFromText: newContents]. > > > > > > contents = newContents > > > ifTrue: [^ self "no substantive change"]. > > > > > > contents := newContents. > > > > > > self fitContents; changed > > > > > > > > > Now maybe the #changed should be added to #fitContents itself. > > > > > > Stef > > > > > > > > > > > |
Hi, all! :-) Thanks for the hints and suggestions. I fixed that in Morphic-mt.1613. Happy new year! Marcel
|
Free forum by Nabble | Edit this page |