diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-06-21 08:25:48 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-06-21 08:25:48 (GMT) |
commit | d616147fcb262851a0e48c3a10c8ae1679f39165 (patch) | |
tree | 70b8418b6411f25e4c83794669e20890644979c2 /library | |
parent | 7f78a312ce4997637ca682626c4dda78a4431c98 (diff) | |
parent | 2c5dfab324feddccbec14a4ab7c453697bf80385 (diff) | |
download | tk-d616147fcb262851a0e48c3a10c8ae1679f39165.zip tk-d616147fcb262851a0e48c3a10c8ae1679f39165.tar.gz tk-d616147fcb262851a0e48c3a10c8ae1679f39165.tar.bz2 |
Merge 8.7
Diffstat (limited to 'library')
-rw-r--r-- | library/menu.tcl | 100 | ||||
-rw-r--r-- | library/print.tcl | 56 | ||||
-rw-r--r-- | library/tearoff.tcl | 10 | ||||
-rw-r--r-- | library/tk.tcl | 2 | ||||
-rw-r--r-- | library/ttk/menubutton.tcl | 2 |
5 files changed, 87 insertions, 83 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index a80e0a2..75e173d 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -269,8 +269,8 @@ proc ::tk::MbPost {w {x {}} {y {}}} { MenuUnpost {} } if {$::tk_strictMotif} { - set Priv(cursor) [$w cget -cursor] - $w configure -cursor arrow + set Priv(cursor) [$w cget -cursor] + $w configure -cursor arrow } if {[tk windowingsystem] ne "aqua"} { set Priv(relief) [$w cget -relief] @@ -343,7 +343,7 @@ proc ::tk::MenuUnpost menu { $menu unpost set Priv(postedMb) {} if {$::tk_strictMotif} { - $mb configure -cursor $Priv(cursor) + $mb configure -cursor $Priv(cursor) } if {[tk windowingsystem] ne "aqua"} { $mb configure -relief $Priv(relief) @@ -475,7 +475,7 @@ proc ::tk::MbButtonUp w { proc ::tk::MenuMotion {menu x y state} { variable ::tk::Priv if {$menu eq $Priv(window)} { - set activeindex [$menu index active] + set active [$menu index active] if {[$menu cget -type] eq "menubar"} { if {[info exists Priv(focus)] && $menu ne $Priv(focus)} { $menu activate @$x,$y @@ -485,24 +485,25 @@ proc ::tk::MenuMotion {menu x y state} { $menu activate @$x,$y GenerateMenuSelect $menu } - set index [$menu index @$x,$y] - if {[info exists Priv(menuActivated)] \ - && $index ne "none" \ - && $index ne $activeindex} { - set mode [option get $menu clickToFocus ClickToFocus] - if {[string is false $mode]} { - set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] - if {[$menu type $index] eq "cascade"} { - # Catch these postcascade commands since the menu could be - # destroyed before they run. - set Priv(menuActivatedTimer) \ - [after $delay "catch {$menu postcascade active}"] - } else { - set Priv(menuDeactivatedTimer) \ - [after $delay "catch {$menu postcascade none}"] - } - } - } + set index [$menu index @$x,$y] + if {[info exists Priv(menuActivated)] \ + && $index ne "none" \ + && $index >= 0 \ + && $index ne $active} { + set mode [option get $menu clickToFocus ClickToFocus] + if {[string is false $mode]} { + set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] + if {[$menu type $index] eq "cascade"} { + # Catch these postcascade commands since the menu could be + # destroyed before they run. + set Priv(menuActivatedTimer) \ + [after $delay "catch {$menu postcascade active}"] + } else { + set Priv(menuDeactivatedTimer) \ + [after $delay "catch {$menu postcascade none}"] + } + } + } } } @@ -525,13 +526,14 @@ proc ::tk::MenuButtonDown menu { variable ::tk::Priv if {![winfo viewable $menu]} { - return + return } - if {[$menu index active] eq "none"} { - if {[$menu cget -type] ne "menubar" } { - set Priv(window) {} - } - return + set active [$menu index active] + if {$active eq "none" || $active < 0} { + if {[$menu cget -type] ne "menubar" } { + set Priv(window) {} + } + return } $menu postcascade active if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} { @@ -552,7 +554,7 @@ proc ::tk::MenuButtonDown menu { if {[$menu type active] eq "cascade"} { set Priv(menuActivated) 1 } - } + } # Don't update grab information if the grab window isn't changing. # Otherwise, we'll get an error when we unpost the menus and @@ -585,7 +587,8 @@ proc ::tk::MenuButtonDown menu { proc ::tk::MenuLeave {menu rootx rooty state} { variable ::tk::Priv set Priv(window) {} - if {[$menu index active] eq "none"} { + set active [$menu index active] + if {$active eq "none" || $active < 0} { return } if {[$menu type active] eq "cascade" \ @@ -653,7 +656,7 @@ proc ::tk::MenuInvoke {w buttonRelease} { } } else { set active [$w index active] - if {$Priv(popup) eq "" || $active ne "none"} { + if {$Priv(popup) eq "" || ($active ne "none" && $active >= 0)} { MenuUnpost $w } uplevel #0 [list $w invoke active] @@ -797,7 +800,8 @@ proc ::tk::MenuNextMenu {menu direction} { if {[winfo class $mb] eq "Menubutton" \ && [$mb cget -state] ne "disabled" \ && [$mb cget -menu] ne "" \ - && [[$mb cget -menu] index last] ne "none"} { + && [[$mb cget -menu] index last] ne "none" \ + && [[$mb cget -menu] index last] >= 0} { break } if {$mb eq $w} { @@ -819,13 +823,14 @@ proc ::tk::MenuNextMenu {menu direction} { # -1 means go to the next higher entry. proc ::tk::MenuNextEntry {menu count} { - if {[$menu index last] eq "none"} { + set last [$menu index last] + if {$last eq "none" || $last < 0} { return } set length [expr {[$menu index last]+1}] set quitAfter $length set active [$menu index active] - if {$active eq "none"} { + if {$active eq "none" || $active < 0} { set i 0 } else { set i [expr {$active + $count}] @@ -893,7 +898,7 @@ proc ::tk::MenuFind {w char} { foreach child $windowlist { # Don't descend into other toplevels. - if {[winfo toplevel $w] ne [winfo toplevel $child]} { + if {[winfo toplevel $w] ne [winfo toplevel $child]} { continue } if {[winfo class $child] eq "Menu" && \ @@ -919,7 +924,7 @@ proc ::tk::MenuFind {w char} { foreach child $windowlist { # Don't descend into other toplevels. - if {[winfo toplevel $w] ne [winfo toplevel $child]} { + if {[winfo toplevel $w] ne [winfo toplevel $child]} { continue } switch -- [winfo class $child] { @@ -941,7 +946,7 @@ proc ::tk::MenuFind {w char} { } } } - return {} + return "" } # ::tk::TraverseToMenu -- @@ -1068,7 +1073,8 @@ proc ::tk::MenuFirstEntry menu { return } tk_menuSetFocus $menu - if {[$menu index active] ne "none"} { + set active [$menu index active] + if {$active ne "none" && $active >= 0} { return } set last [$menu index last] @@ -1115,7 +1121,7 @@ proc ::tk::MenuFindName {menu s} { } set last [$menu index last] if {$last eq "none"} { - return + return "" } for {set i 0} {$i <= $last} {incr i} { if {![catch {$menu entrycget $i -label} label]} { @@ -1186,7 +1192,7 @@ if {[tk windowingsystem] eq "aqua"} { # if we go offscreen to the top, show as 'below' if {$y < [winfo vrooty $button]} { set y [expr {[winfo vrooty $button] + [winfo rooty $button]\ - + [winfo reqheight $button]}] + + [winfo reqheight $button]}] } set entry {} } @@ -1340,14 +1346,12 @@ proc ::tk_menuSetFocus {menu} { proc ::tk::GenerateMenuSelect {menu} { variable ::tk::Priv - if {$Priv(activeMenu) eq $menu \ - && $Priv(activeItem) eq [$menu index active]} { - return + if {$Priv(activeMenu) ne $menu \ + || $Priv(activeItem) ne [$menu index active]} { + set Priv(activeMenu) $menu + set Priv(activeItem) [$menu index active] + event generate $menu <<MenuSelect>> } - - set Priv(activeMenu) $menu - set Priv(activeItem) [$menu index active] - event generate $menu <<MenuSelect>> } # ::tk_popup -- @@ -1369,7 +1373,7 @@ proc ::tk_popup {menu x y {entry {}}} { } tk::PostOverPoint $menu $x $y $entry if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} { - tk::SaveGrabInfo $menu + tk::SaveGrabInfo $menu grab -global $menu set Priv(popup) $menu set Priv(window) $menu diff --git a/library/print.tcl b/library/print.tcl index cfdfa64..e39619d 100644 --- a/library/print.tcl +++ b/library/print.tcl @@ -693,11 +693,11 @@ namespace eval ::tk::print { if {[tk windowingsystem] eq "x11"} { - variable printcmd + variable printcmd variable printlist variable choosepaper variable p - + set printmcd "" set chooseprinter "" set printlist {} @@ -706,11 +706,11 @@ namespace eval ::tk::print { # Set the print environtment - print command, and list of printers. # Arguments: # none. - + proc _setprintenv {} { - variable printcmd + variable printcmd variable printlist - + #Select print command. We prefer lpr, but will fall back to lp if necessary. if {[file exists "/usr/bin/lpr"]} { set printcmd lpr @@ -731,7 +731,7 @@ namespace eval ::tk::print { # Arguments: # w - widget with contents to print. # - + proc _print {w} { variable printlist @@ -742,7 +742,7 @@ namespace eval ::tk::print { variable color variable p - + _setprintenv set chooseprinter [lindex $printlist 0] @@ -750,7 +750,7 @@ namespace eval ::tk::print { set p ._print catch {destroy $p} - + toplevel $p wm title $p "Print" wm resizable $p 0 0 @@ -761,11 +761,11 @@ namespace eval ::tk::print { #The main dialog frame $p.frame.printframe -padx 5 -pady 5 pack $p.frame.printframe -side top -fill x -expand no - - label $p.frame.printframe.printlabel -text "Printer:" + + label $p.frame.printframe.printlabel -text "Printer:" ttk::combobox $p.frame.printframe.mb -textvariable chooseprinter -state readonly -values [lsort -unique $printlist] pack $p.frame.printframe.printlabel $p.frame.printframe.mb -side left -fill x -expand no - + bind $p.frame.printframe.mb <<ComboboxSelected>> { set chooseprinter} set paperlist {Letter Legal A4} @@ -776,7 +776,7 @@ namespace eval ::tk::print { #to the ::tk::print namespace. To minimize name collision, we have #given them similar names to the current namespace. And wherever #possible, we are using namespaced variables. - + set printcopies 1 set ::tkprint_choosepaper A4 set ::tkprint_color RGB @@ -786,7 +786,7 @@ namespace eval ::tk::print { #Base widgets to load. labelframe $p.frame.copyframe -text Options -padx 5 -pady 5 - pack $p.frame.copyframe -fill x -expand no + pack $p.frame.copyframe -fill x -expand no frame $p.frame.copyframe.l -padx 5 -pady 5 pack $p.frame.copyframe.l -side top -fill x -expand no @@ -797,13 +797,13 @@ namespace eval ::tk::print { pack $p.frame.copyframe.l.copylabel $p.frame.copyframe.l.field -side left -fill x -expand no set printcopies [$p.frame.copyframe.l.field get] - + frame $p.frame.copyframe.r -padx 5 -pady 5 pack $p.frame.copyframe.r -fill x -expand no - label $p.frame.copyframe.r.paper -text "Paper:" + label $p.frame.copyframe.r.paper -text "Paper:" tk_optionMenu $p.frame.copyframe.r.menu ::tkprint_choosepaper {*}$paperlist - + pack $p.frame.copyframe.r.paper $p.frame.copyframe.r.menu -side left -fill x -expand no #Widgets with additional options for canvas output. @@ -811,35 +811,35 @@ namespace eval ::tk::print { frame $p.frame.copyframe.z -padx 5 -pady 5 pack $p.frame.copyframe.z -fill x -expand no - + label $p.frame.copyframe.z.zlabel -text "Scale %:" tk_optionMenu $p.frame.copyframe.z.zentry ::tkprint_zoomnumber {*}$percentlist - + pack $p.frame.copyframe.z.zlabel $p.frame.copyframe.z.zentry -side left -fill x -expand no frame $p.frame.copyframe.orient -padx 5 -pady 5 pack $p.frame.copyframe.orient -fill x -expand no - label $p.frame.copyframe.orient.text -text "Orientation:" - radiobutton $p.frame.copyframe.orient.v -text "Portrait" -value portrait -variable ::tkprint_printorientation -compound left - radiobutton $p.frame.copyframe.orient.h -text "Landscape" -value landscape -variable ::tkprint_printorientation -compound left - + label $p.frame.copyframe.orient.text -text "Orientation:" + radiobutton $p.frame.copyframe.orient.v -text "Portrait" -value portrait -variable ::tkprint_printorientation -compound left + radiobutton $p.frame.copyframe.orient.h -text "Landscape" -value landscape -variable ::tkprint_printorientation -compound left + pack $p.frame.copyframe.orient.text $p.frame.copyframe.orient.v $p.frame.copyframe.orient.h -side left -fill x -expand no frame $p.frame.copyframe.c -padx 5 -pady 5 - pack $p.frame.copyframe.c -fill x -expand no + pack $p.frame.copyframe.c -fill x -expand no - label $p.frame.copyframe.c.l -text "Output:" + label $p.frame.copyframe.c.l -text "Output:" tk_optionMenu $p.frame.copyframe.c.c ::tkprint_color {*}$colorlist pack $p.frame.copyframe.c.l $p.frame.copyframe.c.c -side left -fill x -expand no } #Build rest of GUI. - frame $p.frame.buttonframe + frame $p.frame.buttonframe pack $p.frame.buttonframe -fill x -expand no -side bottom button $p.frame.buttonframe.printbutton -text "Print" -command "::tk::print::_runprint $w" - button $p.frame.buttonframe.cancel -text "Cancel" -command {destroy ._print} + button $p.frame.buttonframe.cancel -text "Cancel" -command {destroy ._print} pack $p.frame.buttonframe.printbutton $p.frame.buttonframe.cancel -side right -fill x -expand no @@ -861,7 +861,7 @@ namespace eval ::tk::print { #First, generate print file. - + if {[winfo class $w] eq "Text"} { set txt [$w get 1.0 end] set file /tmp/tk_text.txt @@ -895,7 +895,7 @@ namespace eval ::tk::print { set printargs {} set printcopies [$p.frame.copyframe.l.field get] - + if {$printcmd eq "lpr"} { lappend printargs "-P $chooseprinter -# $printcopies" } else { diff --git a/library/tearoff.tcl b/library/tearoff.tcl index 1c1e5dd..6df8b72 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -79,11 +79,11 @@ proc ::tk::TearOffMenu {w {x 0} {y 0}} { } if {[tk windowingsystem] eq "win32"} { - # [Bug 3181181]: Find the toplevel window for the menu - set parent [winfo toplevel $parent] - while {[winfo class $parent] eq "Menu"} { - set parent [winfo toplevel [winfo parent $parent]] - } + # [Bug 3181181]: Find the toplevel window for the menu + set parent [winfo toplevel $parent] + while {[winfo class $parent] eq "Menu"} { + set parent [winfo toplevel [winfo parent $parent]] + } wm transient $menu [winfo toplevel $parent] wm attributes $menu -toolwindow 1 } diff --git a/library/tk.tcl b/library/tk.tcl index e5e3632..b648f9f 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. # Verify that we have Tk binary and script components from the same release -package require -exact tk 8.7a4 +package require -exact tk 8.7a6 # Create a ::tk namespace namespace eval ::tk { diff --git a/library/ttk/menubutton.tcl b/library/ttk/menubutton.tcl index e82b7c0..a0f70c9 100644 --- a/library/ttk/menubutton.tcl +++ b/library/ttk/menubutton.tcl @@ -136,7 +136,7 @@ if {[tk windowingsystem] eq "aqua"} { # if we go offscreen to the top, show as 'below' if {$y < [winfo vrooty $mb]} { set y [expr {[winfo vrooty $mb] + [winfo rooty $mb]\ - + [winfo reqheight $mb]}] + + [winfo reqheight $mb]}] } } below { |