Skip to content

Commit

Permalink
Some more cleanup, mainly in the Widget Demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
csaba committed Jun 22, 2024
2 parents 86129d0 + d5d68cc commit 7c3e2ff
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 30 deletions.
6 changes: 1 addition & 5 deletions library/demos/ctext.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ $c bind text <Return> "textInsert $c \\n"
$c bind text <Control-h> "textBs $c"
$c bind text <BackSpace> "textBs $c"
$c bind text <Delete> "textDel $c"
if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide tk] 8.7-]} {
$c bind text <Button-3> "textPaste $c @%x,%y"
} else {
$c bind text <Button-2> "textPaste $c @%x,%y"
}
$c bind text <Button-2> "textPaste $c @%x,%y"

# Next, create some items that allow the text's anchor position
# to be edited.
Expand Down
9 changes: 2 additions & 7 deletions library/demos/floor.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1372,13 +1372,8 @@ $c bind floor2 <Button-1> "floorDisplay $c 2"
$c bind floor3 <Button-1> "floorDisplay $c 3"
$c bind room <Enter> "newRoom $c"
$c bind room <Leave> {set currentRoom ""}
if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide tk] 8.7-]} {
bind $c <Button-3> "$c scan mark %x %y"
bind $c <B3-Motion> "$c scan dragto %x %y"
} else {
bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
}
bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
bind $c <Destroy> "unset currentRoom"
set currentRoom ""
trace add variable currentRoom write "roomChanged $c"
15 changes: 4 additions & 11 deletions library/demos/items.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,10 @@ $c create text 28.5c 17.4c -text Scale: -anchor s

$c bind item <Enter> "itemEnter $c"
$c bind item <Leave> "itemLeave $c"
if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide tk] 8.7-]} {
bind $c <Button-2> "itemMark $c %x %y"
bind $c <B2-Motion> "itemStroke $c %x %y"
bind $c <Button-3> "$c scan mark %x %y"
bind $c <B3-Motion> "$c scan dragto %x %y"
} else {
bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
bind $c <Button-3> "itemMark $c %x %y"
bind $c <B3-Motion> "itemStroke $c %x %y"
}
bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
bind $c <Button-3> "itemMark $c %x %y"
bind $c <B3-Motion> "itemStroke $c %x %y"
bind $c <<NextChar>> "itemsUnderArea $c"
bind $c <Button-1> "itemStartDrag $c %x %y"
bind $c <B1-Motion> "itemDrag $c %x %y"
Expand Down
2 changes: 1 addition & 1 deletion library/demos/widget
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exec wish "$0" ${1+"$@"}
# separate ".tcl" files is this directory, which are sourced by this script as
# needed.

package require tk
package require tk 8.7-
package require msgcat

destroy {*}[winfo children .]
Expand Down
10 changes: 4 additions & 6 deletions library/tk.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,12 @@ proc ::tk::PreciseScrollDeltas {dxdy} {
## yview moveto.

proc ::tk::ScrollByPixels {w deltaX deltaY} {
set fracX [lindex [$w xview] 0]
set fracY [lindex [$w yview] 0]
set width [expr {1.0 * [winfo width $w]}]
set height [expr {1.0 * [winfo height $w]}]
set X [lindex [$w xview] 0]
set Y [lindex [$w yview] 0]
set x [expr {$X - $deltaX / $width}]
set y [expr {$Y - $deltaY / $height}]
$w xview moveto $x
$w yview moveto $y
$w xview moveto [expr {$fracX - $deltaX / $width}]
$w yview moveto [expr {$fracY - $deltaY / $height}]
}

# ::tk::TabToWindow --
Expand Down

0 comments on commit 7c3e2ff

Please sign in to comment.