Tk Source Code

Changes On Branch bug-631a0b2d95_revised_text
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-631a0b2d95_revised_text Excluding Merge-Ins

This is equivalent to a diff from b96eea2f to 34516b00

2021-12-04
18:20
Fix [631a0b2d95]: text tag bind of tag covering 1.0 to end stops working after clearing all text and entering new text. This is the fix for the revised text widget. check-in: ccdf2749 user: fvogel tags: revised_text, tip-466
18:19
Cherrypick [ac253bf9] (Document the improvement in the text man page) and fix conflict. Closed-Leaf check-in: 34516b00 user: fvogel tags: bug-631a0b2d95_revised_text
2021-11-19
17:25
Merge 8.7 check-in: 56e0d0dd user: jan.nijtmans tags: revised_text, tip-466
2021-11-14
13:51
Fix [631a0b2d95]: text tag bind of tag covering 1.0 to end stops working after clearing all text and entering new text. The issue actually was dependency on the 'current' mark update by mouse events. Test textTag-15.4 now passes with revised_text. check-in: 0f4cadfa user: fvogel tags: bug-631a0b2d95_revised_text
13:50
Add (currently failing) test textTag-15.4 demonstrating bug [631a0b2d95] with revised_text. check-in: d814c186 user: fvogel tags: bug-631a0b2d95_revised_text
2021-11-13
15:42
Document the improvement in the text man page. Closed-Leaf check-in: ac253bf9 user: fvogel tags: bug-631a0b2d95
2021-11-12
14:54
Merge 8.7 check-in: b96eea2f user: jan.nijtmans tags: revised_text, tip-466
14:52
Merge 8.6 check-in: ff15cbc7 user: jan.nijtmans tags: trunk, main
2021-11-02
08:10
Merge 8.7 check-in: a201c9df user: jan.nijtmans tags: revised_text, tip-466

Changes to doc/text.n.

3768
3769
3770
3771
3772
3773
3774
3775

3776
3777
3778
3779
3780
3781
3782

3783
3784
3785
3786
3787
3788
3789
3790
\fIsequence\fR (an error occurs if there is no such binding). If both
\fIscript\fR and \fIsequence\fR are omitted then the command returns a list of
all the sequences for which bindings have been defined for \fItagName\fR.
.RS
.PP
The only events for which bindings may be specified are those related to the
mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR,
\fBMotion\fR, and \fBKey\fR) or virtual events. Event bindings for a text

widget use the \fBcurrent\fR mark described under \fBMARKS\fR above. An
\fBEnter\fR event triggers for a tag when the tag first becomes present on the
current character, and a \fBLeave\fR event triggers for a tag when it ceases
to be present on the current character. \fBEnter\fR and \fBLeave\fR events can
happen either because the \fBcurrent\fR mark moved or because the character at
that position changed. Note that these events are different than \fBEnter\fR
and \fBLeave\fR events for windows. Mouse and keyboard events are directed to

the current character. If a virtual event is used in a binding, that binding
can trigger only if the virtual event is defined by an underlying
mouse-related or keyboard-related event.
.PP
It is possible for the current character to have multiple tags, and for each
of them to have a binding for a particular event sequence. When this occurs,
one binding is invoked for each tag, in order from lowest-priority to highest
priority. If there are multiple matching bindings for a single tag, then the







|
>
|





|
>
|







3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
\fIsequence\fR (an error occurs if there is no such binding). If both
\fIscript\fR and \fIsequence\fR are omitted then the command returns a list of
all the sequences for which bindings have been defined for \fItagName\fR.
.RS
.PP
The only events for which bindings may be specified are those related to the
mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR,
\fBMotion\fR, and \fBKey\fR) or virtual events. Mouse and keyboard event
bindings for a text widget respectively use the \fBcurrent\fR and \fBinsert\fR
marks described under \fBMARKS\fR above. An
\fBEnter\fR event triggers for a tag when the tag first becomes present on the
current character, and a \fBLeave\fR event triggers for a tag when it ceases
to be present on the current character. \fBEnter\fR and \fBLeave\fR events can
happen either because the \fBcurrent\fR mark moved or because the character at
that position changed. Note that these events are different than \fBEnter\fR
and \fBLeave\fR events for windows. Mouse events are directed to the current
character, while keyboard events are directed to the insert character.
If a virtual event is used in a binding, that binding
can trigger only if the virtual event is defined by an underlying
mouse-related or keyboard-related event.
.PP
It is possible for the current character to have multiple tags, and for each
of them to have a binding for a particular event sequence. When this occurs,
one binding is invoked for each tag, in order from lowest-priority to highest
priority. If there are multiple matching bindings for a single tag, then the

Changes to generic/tkTextTag.c.

2916
2917
2918
2919
2920
2921
2922
2923





2924















2925
2926
2927
2928
2929
2930
2931
	    textPtr->flags &= ~BUTTON_DOWN;
	}
	TkTextPickCurrent(textPtr, eventPtr);
    }
    if (!(textPtr->flags & DESTROYED)) {
	const TkSharedText *sharedTextPtr = textPtr->sharedTextPtr;

	if (sharedTextPtr->tagBindingTable && !TkTextTagSetIsEmpty(textPtr->curTagInfoPtr)) {





	    TagBindEvent(textPtr, eventPtr, textPtr->curTagInfoPtr, sharedTextPtr->tagEpoch);















	    if (textPtr->flags & DESTROYED) {
		TkTextDecrRefCountAndTestIfDestroyed(textPtr);
		return;
	    }
	}
    }
    if (repick) {







|
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
	    textPtr->flags &= ~BUTTON_DOWN;
	}
	TkTextPickCurrent(textPtr, eventPtr);
    }
    if (!(textPtr->flags & DESTROYED)) {
	const TkSharedText *sharedTextPtr = textPtr->sharedTextPtr;

	if (sharedTextPtr->tagBindingTable) {
	    if (!TkTextTagSetIsEmpty(textPtr->curTagInfoPtr)) {
		/*
		 * The mouse is inside the text widget, the 'current' mark was updated.
		 */

		TagBindEvent(textPtr, eventPtr, textPtr->curTagInfoPtr, sharedTextPtr->tagEpoch);
	    } else if ((eventPtr->type == KeyPress) || (eventPtr->type == KeyRelease)) {
		 /*
		  * Key events fire independently of the 'current' mark and use the
		  * 'insert' mark.
		  */

		TkTextIndex index;
		TkTextTagSet *insertTags;

		TkTextMarkNameToIndex(textPtr, "insert", &index);
		insertTags = TkTextIndexGetContentSegment(&index, NULL)->tagInfoPtr;
		if (!TkTextTagSetIsEmpty(insertTags)) {
		    TagBindEvent(textPtr, eventPtr, insertTags, sharedTextPtr->tagEpoch);
		}
	    }
	    if (textPtr->flags & DESTROYED) {
		TkTextDecrRefCountAndTestIfDestroyed(textPtr);
		return;
	    }
	}
    }
    if (repick) {

Changes to tests/textTag.test.

1349
1350
1351
1352
1353
1354
1355


















1356
1357
1358
1359
1360
1361
1362
    event gen .t <ButtonRelease-1> -x $x3 -y $y3 -state 0x300
    lappend x |
    event gen .t <ButtonRelease-2> -x $x3 -y $y3 -state 0x200
    return $x
} -cleanup {
    .t tag delete x y
} -result {x-enter | x-down | | | x-up | x-leave y-enter}




















test textTag-16.1 {TkTextPickCurrent procedure} -setup {
    .t tag delete {*}[.t tag names]
    wm geometry . +200+200 ; update
    event generate {} <Motion> -warp 1 -x 5 -y 5
    controlPointerWarpTiming







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
    event gen .t <ButtonRelease-1> -x $x3 -y $y3 -state 0x300
    lappend x |
    event gen .t <ButtonRelease-2> -x $x3 -y $y3 -state 0x200
    return $x
} -cleanup {
    .t tag delete x y
} -result {x-enter | x-down | | | x-up | x-leave y-enter}

test textTag-15.4 {TkTextBindProc, key event with mouse outside the widget} -setup {
    .t tag delete {*}[.t tag names]
    wm geometry . +200+200 ; update
} -body {
    set res {}
    .t tag add tag1 1.0 end
    .t tag bind tag1 <KeyPress> {lappend res %K}
    .t mark set insert 1.2
    update
    event generate .t <Motion> -warp 1 -x -50 -y -50
    controlPointerWarpTiming
    focus -force .t
    event generate .t <KeyPress> -keysym a
    set res
} -cleanup {
    .t tag delete tag1
} -result {a}


test textTag-16.1 {TkTextPickCurrent procedure} -setup {
    .t tag delete {*}[.t tag names]
    wm geometry . +200+200 ; update
    event generate {} <Motion> -warp 1 -x 5 -y 5
    controlPointerWarpTiming