Tk Source Code

Changes On Branch bug-631a0b2d95
Login

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

Changes In Branch bug-631a0b2d95 Excluding Merge-Ins

This is equivalent to a diff from d676416a to ac253bf9

2021-12-04
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
18:12
Fix [631a0b2d95]: text tag bind of tag covering 1.0 to end stops working after clearing all text and entering new text. check-in: 3031278b user: fvogel tags: core-8-6-branch
2021-11-16
10:56
Add DEF_LABEL_FG for all platforms, not only MacOS. Backport some type-casts from 8.7 check-in: 570648c7 user: jan.nijtmans tags: core-8-6-branch
2021-11-13
15:42
Document the improvement in the text man page. Closed-Leaf check-in: ac253bf9 user: fvogel tags: bug-631a0b2d95
15:30
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. check-in: ea53bc2f user: fvogel tags: bug-631a0b2d95
15:28
Add (currently failing) test textTag-15.4 demonstrating bug [631a0b2d95]. check-in: 1c52a01f user: fvogel tags: bug-631a0b2d95
2021-11-12
14:52
Merge 8.6 check-in: ff15cbc7 user: jan.nijtmans tags: trunk, main
14:36
Fix [d6a1bc30cd]: Order of bindings in man bind doesn't reflect the default bindtags. check-in: d676416a user: fvogel tags: core-8-6-branch
12:31
Fix [d6a1bc30cd]: Order of bindings in man bind doesn't reflect the default bindtags Closed-Leaf check-in: b4528784 user: fvogel tags: bug-d6a1bc30cd
2021-11-11
16:11
Fix -fno-lto determination/add --enable-auto-image-base option to windows build (when available) check-in: 29f37cdc user: jan.nijtmans tags: core-8-6-branch

Changes to doc/text.n.

1728
1729
1730
1731
1732
1733
1734
1735

1736
1737
1738
1739
1740
1741
1742

1743
1744
1745
1746
1747
1748
1749
1750
\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, \fBButtonPress\fR,
\fBMotion\fR, and \fBKeyPress\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







|
>
|





|
>
|







1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
\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, \fBButtonPress\fR,
\fBMotion\fR, and \fBKeyPress\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.

1477
1478
1479
1480
1481
1482
1483
1484
1485
1486





1487
1488















1489
1490
1491
1492
1493
1494
1495
	if (eventPtr->xmotion.state & ALL_BUTTONS) {
	    textPtr->flags |= BUTTON_DOWN;
	} else {
	    textPtr->flags &= ~BUTTON_DOWN;
	}
	TkTextPickCurrent(textPtr, eventPtr);
    }
    if ((textPtr->numCurTags > 0)
	    && (textPtr->sharedTextPtr->bindingTable != NULL)
	    && (textPtr->tkwin != NULL) && !(textPtr->flags & DESTROYED)) {





	TagBindEvent(textPtr, eventPtr, textPtr->numCurTags,
		textPtr->curTagArrayPtr);















    }
    if (repick) {
	unsigned int oldState;

	oldState = eventPtr->xbutton.state;
	eventPtr->xbutton.state &= ~(unsigned long)ALL_BUTTONS;
	if (!(textPtr->flags & DESTROYED)) {







|
|

>
>
>
>
>
|

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







1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
	if (eventPtr->xmotion.state & ALL_BUTTONS) {
	    textPtr->flags |= BUTTON_DOWN;
	} else {
	    textPtr->flags &= ~BUTTON_DOWN;
	}
	TkTextPickCurrent(textPtr, eventPtr);
    }

    if ((textPtr->sharedTextPtr->bindingTable != NULL)
	    && (textPtr->tkwin != NULL) && !(textPtr->flags & DESTROYED)) {
	if (textPtr->numCurTags > 0) {
	    /*
	     * The mouse is inside the text widget, the 'current' mark was updated.
	     */

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

	    TkTextIndex index;
	    TkTextTag** tagArrayPtr;
	    int numTags;

	    TkTextMarkNameToIndex(textPtr, "insert", &index);
	    tagArrayPtr = TkBTreeGetTags(&index, textPtr, &numTags);
	    SortTags(numTags, tagArrayPtr);
	    TagBindEvent(textPtr, eventPtr, numTags, tagArrayPtr);
	}
    }
    if (repick) {
	unsigned int oldState;

	oldState = eventPtr->xbutton.state;
	eventPtr->xbutton.state &= ~(unsigned long)ALL_BUTTONS;
	if (!(textPtr->flags & DESTROYED)) {

Changes to tests/textTag.test.

1575
1576
1577
1578
1579
1580
1581


















1582
1583
1584
1585
1586
1587
1588
    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} -constraints {
    haveCourier12
} -setup {
    .t tag delete {*}[.t tag names]
    wm geometry . +200+200 ; update







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







1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
    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} -constraints {
    haveCourier12
} -setup {
    .t tag delete {*}[.t tag names]
    wm geometry . +200+200 ; update