Thursday, May 05, 2005

Tweak gotcha..

This one took hour or two to down. I wonder if I am abusing an idiom.

I wanted to create a dialog with custom behaviors so I did the following.

d := CFileSaveDialog new.
d costume: CCFileSaveDialogCostumeCITRIS new.
d openLabel: 'Test Custom Dialog'.

then in CCFileSaveDialogCostumeCITRIS>>initialize I added changed around parameters:

directoryList costume: CTreeWidgetCostumeCitris new. "works"
player sorter primarySort: #compareType:with:. "does NOT work"

The problem is the timing. initialize gets called at the end of the new, and before the costume: call, so player in initialize has not been set to d. Instead CPlayer has silently stuck in a default CFileDialog that gets modified and then immediately discarded.

If I move the player modifying line into onPlayerChanged, it is all good.