Advanced Dynamic Functionality
This example shows that the front end can remain responsive no matter how long the final display takes to compute and that the preview and the final display can be completely different.
Of course, in most cases, you will want a preview that is some kind of reduced, thinned out, skeletal, or other elided form of the final display. Then the crude form can be fast enough to give a smooth preview, and the computation of the final version, even if it takes awhile, does not block the front end. In fact, this behavior is so useful that it is the default in Plot3D and other plotting functions.
ImageSizeCache is an option to Dynamic that specifies a rectangular size to be used in displaying a Dynamic whose value has not yet been computed. It is normally not specified in input, but is instead generated automatically by the front end and saved in files along with the Dynamic expression.
Note first that Dynamic expressions with the default value of SynchronousUpdating->True will never have a chance to use the value of their ImageSizeCache option, because they are always computed before being displayed, and, once computed, the actual image size will be used.
After evaluating in the kernel, ControlActive can trigger an update of the Dynamic containing it, but in a highly asymmetric fashion, only when it is going from the active to the inactive state. When making a transition in the other direction, from inactive to active, ControlActive does not trigger any update on its own.
The reason for this somewhat unusual behavior is that ControlActive is a completely global concept. It returns the active state if any control anywhere in the Wolfram System is currently being dragged—even controls that have nothing to do with a particular Dynamic that happen to contain a reference to ControlActive. If ControlActive caused updates on its own, then as soon as you clicked any control, all Dynamic expressions containing references to ControlActive (e.g., a default dynamic Plot3D output) would immediately update, which would be entirely pointless. Instead, only those outputs that have some other reason for updating will pick up the current value of ControlActive.
On the other hand, when the control is released, it is desirable to fix up any outputs that were drawn in control-active form, to give them their final polished appearance. Thus, when ControlActive is going into its inactive state, it needs to, on its own, issue updates to any Dynamic expression that may have been drawn in the active state.
Clicking the + button increments the value of a DynamicModule local variable, which is displayed at the end of the output. To decrement the number you have to click the Make - Palette button, which creates a new (very small) floating palette window containing a - button.