A PRIMER FOR PROGRAMMING PAD++ IN TCL/TK

Item IDs and Tags

Items on a Pad++ widget may be named in either of two ways: by id or by tag. Each item has a unique identifying number (its id), which is assigned to that item when it is created. The id of an item never changes and id numbers are never re-used within the lifetime of a pad widget. The surface itself always gets an id of '1'. (It is sometimes useful to manually set the id of an item. This is possible with the setid command.)

Each item may also have any number of tags associated with it. A tag is just a string of characters, and it may take any form except that of an integer. For example, "x123" is OK, but "123" isn't. The same tag may be associated with many different items. This is commonly done to group items in various interesting ways; for example, all items associated with one user might have a tag with that user's name. Then, all of those items can be modified by referring to that tag. Note that Pad++ also has a special group item for creating hierarchical groups.

The tag all is implicitly associated with every item on the Pad++ widget; it may be used to invoke operations on all the items in the pad.

The tag current is managed automatically. It applies to the current item, which is the topmost item whose drawn area covers the position of the mouse cursor. Note that events only go to the current item. Since an item gets the current tag only if the cursor is over the drawn area, this means that an item receives events only when the cursor is over the drawn area. For example, a rectangle with no fill color will not respond to events when the cursor is over the undrawn interior. If the mouse is not in the pad widget or is not over an item, then no item has the current tag. Portal items are treated somewhat differently, however, as described in the bind command and in the description of Portal Items in the reference manual.

When specifying items in Pad++ widget commands, if the specifier is an integer then it is assumed to refer to the single item with that id. If the specifier is not an integer, then it is assumed to be a tag, and refers to all of the items on the Pad++ widget that have that tag. The symbol tagOrId is used to indicate that a tag or an id is to be used as an argument to the command. For example, the manual entry for the command slide looks like this: pathName slide tagOrId. An id selects a single item (which may be a group item), and a tag selects zero or more items to be used by the command. Some widget commands only operate on a single item at a time. If tagOrId specifies multiple items, then the normal behavior is for the command to use the first (lowest) of these items in the display list that is suitable for the command. Exceptions are noted in the widget command descriptions.

There are commands to find the specific tags associated with an item (gettags), and to find all the items that share a tag (find). Tags can be added to items with the addtag command or deleted with the deletetag command. In addition, tags can be accessed with the -tags itemconfigure option.


Pad++ Programmer's Guide - 10 JUN 1996

Generated with Harlequin WebMaker

Web Accessibility