Skip to content

Commit

Permalink
Merge 8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 28, 2024
2 parents 748f5f9 + 5120718 commit 64ef8f9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
9 changes: 6 additions & 3 deletions library/entry.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ proc ::tk::EntryTranspose w {

if {[tk windowingsystem] eq "win32"} {
proc ::tk::EntryNextWord {w start} {
if {[$w cget -show] ne ""} {
# the check on [winfo class] is because the spinbox also uses this proc
if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
return end
}
set pos [tk::endOfWord [$w get] [$w index $start]]
Expand All @@ -613,7 +614,8 @@ if {[tk windowingsystem] eq "win32"} {
}
} else {
proc ::tk::EntryNextWord {w start} {
if {[$w cget -show] ne ""} {
# the check on [winfo class] is because the spinbox also uses this proc
if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
return end
}
set pos [tk::endOfWord [$w get] [$w index $start]]
Expand All @@ -634,7 +636,8 @@ if {[tk windowingsystem] eq "win32"} {
# start - Position at which to start search.

proc ::tk::EntryPreviousWord {w start} {
if {[$w cget -show] ne ""} {
# the check on [winfo class] is because the spinbox also uses this proc
if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
return 0
}
set pos [tk::startOfPreviousWord [$w get] [$w index $start]]
Expand Down
6 changes: 4 additions & 2 deletions library/ttk/entry.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ set ::ttk::entry::State(startNext) \
[string equal [tk windowingsystem] "win32"]

proc ttk::entry::NextWord {w start} {
if {[$w cget -show] ne ""} {
# the check on [winfo class] is because the spinbox and combobox also use this proc
if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
return end
}
variable State
Expand All @@ -274,7 +275,8 @@ proc ttk::entry::NextWord {w start} {
## PrevWord -- Find the previous word position.
#
proc ttk::entry::PrevWord {w start} {
if {[$w cget -show] ne ""} {
# the check on [winfo class] is because the spinbox and combobox also use this proc
if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
return 0
}
set pos [tk::startOfPreviousWord [$w get] [$w index $start]]
Expand Down
20 changes: 20 additions & 0 deletions tests/spinbox.test
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,26 @@ test spinbox-25.1 {textvariable lives in a non-existing namespace} -setup {
} -cleanup {
destroy .s
} -result {can't trace "thisnsdoesntexist::myvar": parent namespace doesn't exist}
test spinbox-25.3 {Bugs [2a32225cd1] and [9fa3e08243]} -setup {
destroy .s
pack [spinbox .s]
update
set res {}
} -body {
.s insert end "A sample text"
.s icursor end
event generate .s <<PrevWord>> ; # shall move insert to index 9
.s delete insert end
lappend res [.s get]
.s delete 0 end
.s insert end "A sample text"
.s icursor 2
event generate .s <<NextWord>> ; # shall move insert to index 9
.s delete 0 insert
lappend res [.s get]
} -cleanup {
destroy .s
} -result {{A sample } text}

# Collected comments about lacks from the test
# XXX Still need to write tests for SpinboxBlinkProc, SpinboxFocusProc,
Expand Down
21 changes: 21 additions & 0 deletions tests/ttk/spinbox.test
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,27 @@ test spinbox-4.2 "Increment with duplicates in -values, no wrap" -setup {
unset -nocomplain ::spinbox_test max
} -result {one two three 4 5 two six six six two 5 4 three two one one one one}

test spinbox-11.2 {Bugs [2a32225cd1] and [9fa3e08243]} -setup {
destroy .s
pack [ttk::spinbox .s]
update
set res {}
} -body {
.s insert end "A sample text"
.s icursor end
event generate .s <<PrevWord>> ; # shall move insert to index 9
.s delete insert end
lappend res [.s get]
.s delete 0 end
.s insert end "A sample text"
.s icursor 2
event generate .s <<NextWord>> ; # shall move insert to index 9
.s delete 0 insert
lappend res [.s get]
} -cleanup {
destroy .s
} -result {{A sample } text}


# nostomp: NB intentional difference between ttk::spinbox and tk::spinbox;
# see also #1439266
Expand Down

0 comments on commit 64ef8f9

Please sign in to comment.