Tk Source Code

Check-in [14510abd]
Login

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

Overview
Comment:Add more <<Selection>> event generation tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-b68710aed6
Files: files | file ages | folders
SHA3-256: 14510abd5c05bdab61b5d05795a65ae801b3e3f0794637651793a42cd83ad62e
User & Date: fvogel 2018-01-18 00:29:00
Context
2018-01-18
00:42
Deal with the case of selection modification by insertion. All tests about <<Selection>> now pass, and no test is newly failing. Closed-Leaf check-in: 6e14c473 user: fvogel tags: bug-b68710aed6
00:29
Add more <<Selection>> event generation tests. check-in: 14510abd user: fvogel tags: bug-b68710aed6
2018-01-16
20:29
Deal with the case of selection modification by deletion. This makes text-27.15b and text-27.15c pass. check-in: 4599d5ab user: fvogel tags: bug-b68710aed6
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/text.test.

6403
6404
6405
6406
6407
6408
6409
6410

6411












6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424














6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
















6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456














6457
6458
6459
6460
6461
6462
6463
    .t insert end "nothing special\n"
    .t tag add sel 1.0 1.1
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {selection_changed}
test text-27.15a {<<Selection>> virtual event on <<PasteSelection>>} -body {

    pack [text .t]












    .t insert end "There is a selection in this text widget, "
    .t insert end "and it will be impacted by the <<PasteSelection>> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<PasteSelection>> -x 15 -y 3
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}














test text-27.15b {<<Selection>> virtual event on <Delete>} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget, "
    .t insert end "and it will be impacted by the <Delete> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    .t mark set insert 1.15
    focus .t
    event generate .t <Delete>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}
















test text-27.15c {<<Selection>> virtual event on <<Cut>>} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget, "
    .t insert end "and it will be impacted by the <<Cut>> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<Cut>>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}














test text-27.16 {-maxundo configuration option} -body {
    text .t -undo 1  -autoseparators 1 -maxundo 2
    pack .t
    .t insert end "line 1\n"
    .t delete 1.4 1.6
    .t insert end "line 2\n"
    catch {.t edit undo}







|
>

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












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

|














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

|












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







6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
    .t insert end "nothing special\n"
    .t tag add sel 1.0 1.1
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {selection_changed}
test text-27.15a {<<Selection>> virtual event on sel removal} -body {
    set ::retval no_selection
    pack [text .t]
    .t insert end "nothing special\n"
    .t tag add sel 1.0 1.1
    bind .t <<Selection>> "set ::retval selection_changed"
    update idletasks
    .t tag remove 1.0 end
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {selection_changed}
test text-27.15b {<<Selection>> virtual event on <<PasteSelection>> inside widget selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "and it will be impacted by the <<PasteSelection>> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<PasteSelection>> -x 15 -y 3
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}
test text-27.15c {No <<Selection>> virtual event on <<PasteSelection>> outside widget selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "but it will not be impacted by the <<PasteSelection>> event received."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<PasteSelection>> -x 15 -y 80
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {no_<<Selection>>_event_fired}
test text-27.15d {<<Selection>> virtual event on <Delete> with cursor inside selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "and it will be impacted by the <Delete> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    .t mark set insert 1.15
    focus .t
    event generate .t <Delete>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}
test text-27.15e {No <<Selection>> virtual event on <Delete> with cursor outside selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "but it will not be impacted by the <Delete> event received."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    .t mark set insert 2.15
    focus .t
    event generate .t <Delete>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {no_<<Selection>>_event_fired}
test text-27.15f {<<Selection>> virtual event on <<Cut>> with a widget selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "and it will be impacted by the <<Cut>> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    .t tag add sel 1.0 1.28
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<Cut>>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {<<Selection>>_fired}
test text-27.15g {No <<Selection>> virtual event on <<Cut>> without widget selection} -body {
    pack [text .t]
    .t insert end "There is a selection in this text widget,\n"
    .t insert end "and it will be impacted by the <<Cut>> event received.\n"
    .t insert end "Therefore a <<Selection>> event must fire back."
    bind .t <<Selection>> "set ::retval <<Selection>>_fired"
    update
    set ::retval no_<<Selection>>_event_fired
    event generate .t <<Cut>>
    update
    set ::retval
} -cleanup {
    destroy .t
} -result {no_<<Selection>>_event_fired}
test text-27.16 {-maxundo configuration option} -body {
    text .t -undo 1  -autoseparators 1 -maxundo 2
    pack .t
    .t insert end "line 1\n"
    .t delete 1.4 1.6
    .t insert end "line 2\n"
    catch {.t edit undo}