Visualization Tools User's Guide


Example: Watch Expression

Suppose that you want to know how big the transcript window is, in pixels. You'd like this number to be easy to update. Unfortunately, it's not an instance variable of the transcript window or anything else. So, the Snooper allows you to write a block of code and display its result.

  1. Open a Snooper by evaluating Transcript snoop.
  2. Select the self line.
  3. From Hide select Watch Expression. (Or, select Watch Expression from the popup menu.)
  4. A window titled (Code) appears
    Code window
  5. In the Show value of: box, complete the text to read [:x | x textWidget width * x textWidget height]
  6. Modify the Call it: field to read widget area.
    Widget window
  7. Click on Do It.
  8. Observe that a new name widget area has appeared, just as if it were an instance variable. The actual value will vary, depending on how big your Transcript window actually is.
    Add Widget Area
  9. Change the size of your Transcript window. Note that the value of the widget area in the Snooper does not change -- the Snooper has no way of knowing that it should be updated.
  10. Double-click any line of the Snooper, or press the Rebuild button. Note that the value of the widget area is updated to reflect the current size.


[ Top of Page | Previous Page | Next Page | Table of Contents ]