Friday, April 29, 2005

Tweak values & players

Ok, I think I am getting a hang of the tweak way of thinking.
Lets say I have a CColorPicker & I want to use it in a dialog & do something with it. There are a couple of ways of doing this.
The color selected by the user updates the colorPicker's value. So I can:
  1. In the dialog's initialize, call self startScript: #doSomething when: { colorPicker. #valueChanged}
  2. in the doSomething method (which should prob be called onColorChanged), put . I think that just tells tweak to magically add the line above to the init for me.
  3. I can call colorPicker player: ( self fieldNamed: #someField ) which puts a CFieldReference into the colorPicker as it's value. So the field in the dialog is updated in sync with the colorPicker's value. This has something to do with Tweak's virtual field mechanism, which I don't fully understand, but it seems very cool.