Pad++ Programmer's Guide

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 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. 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 refer to all of the items on the Pad++ widget that have a tag matching that specifier. The symbol tagOrId is used to indicate that an argument specifies either an id that selects a single item or a tag that selects zero or more items. Some widget commands only operate on a single item at a time; if tagOrId is specified in a way that names multiple items and the command only operates on a single item, 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 what the tags of a specific item are (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, and the hastag command determines if an item has a particular tag.


Pad++ Programmer's Guide - 20 JUN 1997

Copyright Computer Science Department, The University of New Mexico

Web Accessibility