November 1999
Intermediate to advanced
832 pages
19h 28m
English
Example 34-2 creates an object that you can drag around with the mouse. It introduces the use of tags to classify objects. In this case the movable tag gets bindings that let you drag the item, so any item with the movable tag shares this behavior. The example uses Scrolled_Canvas from Example 34-1. When you use a scrolled canvas, you must map from the view coordinates reported by bindings to the canvas coordinates used to locate objects:
proc CanvasHello {} { set can [Scrolled_Canvas .c -width 400 -height 100 \ -scrollregion {0 0 800 400}] pack .c -fill both -expand true # Create a text object on the canvas $can create text 50 50 -text "Hello, World!" -tag movable # Bind actions ... |
Read now
Unlock full access