TIP 236: Absolute Positioning of Canvas Items

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Neil McKay <mckay@eecs.umich.edu>
State:          Final
Type:           Project
Vote:           Done
Created:        25-Dec-2004
Post-History:   
Keywords:       Tk,anchor,place
Tcl-Version:    8.6

Abstract

This TIP proposes adding a canvas widget command to set the absolute position of canvas items.

Rationale

There are many situations where it is desirable to move a group of canvas items to a given position. Currently, this is done by getting the items' first coordinate, calculating the offset required to move the items to the desired position, and using the canvas move command to translate the items to where we want them. This is tedious and inefficient.

The 'moveto' Canvas Command

This TIP proposes adding a subcommand called moveto to the canvas widget command. It is analogous to the canvas move command, except that it accepts an absolute position instead of a relative displacement. For instance, the command

	.c moveto stuff 100 200

will displace all items tagged with stuff so that the first coordinate of the first (bottom-most) tagged item lies at the point (100,200).

The result of the command will be the empty string.

Formal Syntax

canvas moveto tagOrId x y

Argument description:

canvas: The canvas instance's command.

tagOrId: A specifier that selects one or more items. If no items are selected, the command does nothing.

x, y: The absolute coordinates of the target location. If either coordinate is given as an empty string, then that coordinate will remain unchanged.

Patches

A patch (against tcl8.5a3) that implements the moveto canvas subcommand is available http://www.eecs.umich.edu/~mckay/canvmoveto.patch.gz .

Copyright

This document is in the public domain.

History