I've seen some comments about how tweak isn't smalltalk. That
shouldn't be confused with what tweak can do for you.
I think some examples are in order to expose how easy it is to build
GUI's in and to indicate the non-traditional smalltalk parts.
Comments about CPlayer and CCostume can come from others.
If for example I create a class subclassed off of CPlayer and want to
capture a mouse down, change the color of the player, then change back
to the original color on the mouse up.
I would code this method
onMouseDown
| oldColor |
<on: mouseDown>
oldColor _ color.
color _ Color yellow.
self waitUntil: #mouseUp.
color _ oldColor.
The non-smalltalk part is the <on: mouseDown> which populates a
dictionary at compile/accept time with the fact that on a mouseDown
event I want this onMouseDown method to be called.
I could of course populate that dictionary with this information as
part of instantiating an object, but having it here visually ensures
we do not lose track of doing that and I can clearly see what the
responsibility of this method is. So on mouse down this method gets
executed asynchronously, and I set the color of the CPlayer which
makes it yellow.
Now the question is how do we wait for the mouse up, easy I do the
self waitUntil: #mouseUp. So execution pauses on this asynchronous
process, other UI things continue to run, once the mouse goes up, the
color is changed back.
Doing this in morphic would be a lot harder. Someone is welcome to
code up an example?
Keep in mind as a replacement for Morphic Tweak is building on lessons
learned, it's much more mature product and finding things are in most
cases easy and found where you would expect to find them, versus say
the mysteries of Morphic.