PrevUpNext devguide-14.htmlThe class Protocols devguide-9.htmlThe Document and Graphics Classes devguide-16.htmlThe class Primitive The class Selectable
The class Selectable defines the interface for objects that can
be selected with the mouse. This includes tests for whether the object
is hit by a mouse click and methods for the handles.
The Selection Mechanism
Yet to be written...
Methods
A Selectable object has these methods:
Hit(p, rect, device[, 
clip])Return true if clicking at p (a devguide-5.htmlpoint object ) should select the object. The
parameter 
device is a graphics device that
can convert points between 
devguide-4.htmldocument
coordinates and window coordinates
. p is always given in
document coordinates.
rect is a devguide-6.htmlrect object  in
doc-coordinates that describes a small area around 
p (a
few pixels wide). A point of the object should be considered
`hit' if it lies inside this rectangle.
The device parameter is necessary, because clicking on a
special point should have some tolerance, so that `missing' by a
few pixels still selects that point. Unfortunately, pixels are
screen coordinates and the object's coordinates are document
coordinates, so conversion between the two is sometimes
necessary. 
device has some methods for this and also for
testing if certain primitives are hit. Currently 
device is
an instance of 
HitTestDevice
The optional parameter clip is only provided if the object
is used as a clip mask. If it is provided its value is 1.
Objects that can be used as clip masks (their 
is_clip flag
is true) should test whether 
p is inside of the object
regardless of whether they are filled or not. Objects that
cannot be used as clip masks don't need to accept it.
SelectSubobject(p, rect, device[, path])When the parent decides that one of its children (or one of the
child's descendants) is to be selected (this is determined using
the children's bounding rects and their 
Hit methods), it
calls this method to ask the child for details.
Normally, self should be returned (this is also the default
behavior). To select a subobject, return selection info
relative to self as a single tuple of selection info. (see
selinfo.py) 
Compound objects like groups and layers override this method to
let the user select their children.
As in #N5Hit , p and rect describe a
point and a small tolerance rectangle around it, and 
deviceis a 
HitTestDevice. The optional argument
path is useful only for compound objects  but
has to be accepted by all graphics objects. 
devguide-14.htmlThe class Protocols devguide-9.htmlThe Document and Graphics Classes devguide-16.htmlThe class Primitive PrevUpNext