From 04b5b8308a21d68a6850624faa9dfe3988363c94 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 23 Dec 2019 13:58:50 +0000 Subject: Add test canvText-14.7, currently failing and demonstrating bug [1771594fff] --- tests/canvText.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/canvText.test b/tests/canvText.test index b2af39b..76903d7 100644 --- a/tests/canvText.test +++ b/tests/canvText.test @@ -803,6 +803,25 @@ test canvText-14.6 {select clear errors} -setup { } -cleanup { .c delete test } -returnCodes error -result "wrong \# args: should be \".c select clear\"" +test canvText-14.7 {GetTextIndex procedure: pixel index with non-default scrollregion} -setup { + canvas .cc + .cc create text 50 80 -tag test -text Hello -anchor nw -font "Arial 30" + foreach {xmin ymin xmax ymax} [.cc bbox test] {} +} -body { + # default -scrollregion + set res [.cc index test @$xmin,$ymin] + lappend res [.cc index test @$xmax,$ymax] + # -scrollregion with positive upper left corner + .cc configure -scrollregion {50 50 700 900} + lappend res [.cc index test @$xmin,$ymin] + lappend res [.cc index test @$xmax,$ymax] + # -scrollregion with negative upper left corner + .cc configure -scrollregion {-100 -100 700 900} + lappend res [.cc index test @$xmin,$ymin] + lappend res [.cc index test @$xmax,$ymax] +} -cleanup { + destroy .cc +} -result {0 5 0 5 0 5} test canvText-15.1 {SetTextCursor procedure} -setup { .c create text 0 0 -tag test -- cgit v0.12 From ecf107511446fc5f2143d963b23f5a63020a04b3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 23 Dec 2019 13:59:54 +0000 Subject: Fix [1771594fff]: icursor @x,y fails for non-default scrollregions. Test canvText-14.7 now passes. --- generic/tkCanvText.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 84b2a23..48c0a9d 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -1392,8 +1392,8 @@ GetTextIndex( goto badIndex; } y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5); - x += canvasPtr->scrollX1 - (int) textPtr->drawOrigin[0]; - y += canvasPtr->scrollY1 - (int) textPtr->drawOrigin[1]; + x -= (int) textPtr->drawOrigin[0]; + y -= (int) textPtr->drawOrigin[1]; *indexPtr = Tk_PointToChar(textPtr->textLayout, (int) (x*c - y*s), (int) (y*c + x*s)); } else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) { -- cgit v0.12