Tk Source Code

View Ticket
Login
Ticket UUID: 279b027fd74d2e37a0e6104de165c55e6b28f8d0
Title: Canvas moveto command moves text items to unexpected location
Type: Bug Version: 8.6.2
Submitter: sbron Created on: 2014-09-11 14:21:00
Subsystem: 05. Canvas Items Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-01-18 11:35:40
Resolution: Fixed Closed By: fvogel
    Closed on: 2020-01-18 11:35:40
Description:
I expected the canvas moveto subcommand to move a text item to the specified location. However it ends up at some offset. The following code returns something like 24.0 17.0 instead of 10.0 10.0, as I would have expected.

canvas .c
set id [.c create text 0 0 -text hello]
.c moveto $id 10 10
puts [.c coords $id]

It seems that moveto actually uses the bbox coordinates of the text item rather than the coordinates as returned by the coords subcommand, judging by the fact that [.c bbox $id] returns "10 10 39 24" after the moveto.

If that is the intended behavior of the command, it could at least do with a clearer description in the manual page.
User Comments: fvogel added on 2020-01-18 11:35:40:
Merged into core-8-6-branch and trunk.

fvogel added on 2019-12-25 18:11:03:

Indeed the "canvas moveto" command computes the translation vector from the upper-left corner of the item bounding box to the given moveto coordinates.

I made that clearer in the documentation in [98f7055781].