Class ::tycho::Selector


Inherits: ::tycho::Interactor - Source File - Contents: public methods - public variables - protected methods - protected variable
A Selector is an interactor that selects items. It can be configured to select items by clicking, toggle items in and out of the selection set, and, together with another mouse-follower interactor, supports drag-selecting.

Currently, selected items are highlighted by drawing a rectangle around them -- later this might be made more sophisticated.


Public constructs

Public Methods

clear
Deselect all tagged items.
contents
Return the selected items.
highlight tag
Return a tag that represents highlight items of the given id or tag. Note: just because this method returns something does not mean that a highlight actually exists. Use "all" to get a tag for all selected items.
selected id
Test if an item is already selected.
tag
Return a tag that represents the selected items.

Public Variables

-dragmode overlapping
The drag-select mode: "overlapping" or "enclosed".
-dragcolor grey
The color of the drag-select box.
-deselectcommand
A script executed when an item is deselected. Two arguments are passed: this interactor and the selected picture.
-highlightcolor cyan
The color of the highlight box.
-highlightwidth 2
The width of the highlight box.
-selectcommand
A script executed when an item is selected. Two arguments are passed: this interactor and the selected picture.
-movepredicate
A script that controls whether interaction events are forwarded to the slate (or proxy) or not. If this script is null, then events are forwarded; if it is not null, then commands are forwarded only if it returns true. It has no arguments.

Protected constructs

Protected Methods

activate t x y args
Add a picture object to the selected objects. Apart from the standard -button and -modifiers options, the method also responds to the following (meaning that these options can be given when the call to bind is made.):

.
click x y args
Start an interaction sequence. The behaviour depends on the current "mode" of the selector: in move mode, the default behaviour is used (which usually moves the selected objects); in drag or altdrag modes, this method creates a drag outline.

Note that the drag and altdrag modes are used only if this selector is a proxy of another mouse follower of some kind. (Sorry if this is obscure, I'll try to explain it better later.).

deselect id
Remove an item from the set of selected items.
drag x y
Continue an interaction sequence with a mouse move. The behaviour depends on the current "mode" of the selector: in move mode, the default behaviour is used (which usually moves the selected objects); in drag or altdrag modes, this method moves the drag outline and selects and deselects objects within the region.
deactivate args
Deactivate the interactor from the target. This method must be called by the script bound to the release event.
release
Terminate an interaction sequence. The behaviour depends on the current "mode" of the selector: in move mode, the default behaviour is used; in drag or altdrag modes, this method deletes the selection drag box.
select id
When a picture is selected, it is tagged with "sel.$this" to indicate that it is selected, and "move.$this" so that it can be moved. The highlight box (or whatever) is tagged with "box.$this" so it can be accessed later, "move.$this" so it is moved together with the other selected items, and "box.$this.$id" also so it can be access later. Do not assume use these tags directly, as they may change.

If directly doing things with objects, you have to take care that highlights are operated on too. The safest approach is to clear the selection. If you don't want to do that, use the highlight method to get an item or tag that represents the actual highlight items.

Note: Do not call this method if the item is already selected! Use the selected method to test if necessary.

Protected Variable

inhibit 0
The flag controlling forwarding of interaction commands.

Index of classes



Author: H. John Reekie
Version: @(#)Selector.itcl 1.6 12/13/96
Copyright: (c) 1996 The Regents of the University of California.