Tk Library Source Code

Artifact [bd150ac4ae]
Login

Artifact bd150ac4ae71c0fca5eb6f51d57bc90d564d169c877bb6cc04a77277a54073c0:

Attachment "tooltip.diff" to ticket [94146a51e8] added by mathias 2022-09-25 22:48:48. (unpublished)
diff -ru orig/modules/tooltip/tooltip.man new/modules/tooltip/tooltip.man
--- orig/modules/tooltip/tooltip.man	2022-09-26 00:13:43.046418300 +0200
+++ new/modules/tooltip/tooltip.man	2022-09-26 00:42:19.158502300 +0200
@@ -110,6 +110,14 @@
 The tag should already be present when this command is called, or an error will
 be returned. The widget must be a text widget.
 
+[opt_def -heading [arg columnId]]
+
+This option is used to set a tooltip for a ttk::Treeview column heading.
+The column does not need to already exist. You should not use the same
+identifiers for columns and items in a widget for which you are using tooltips
+as their tooltips will be mixed.
+The widget must be a ttk::Treeview widget.
+
 [opt_def --]
 
 The [option --] option marks the end of options.
diff -ru orig/modules/tooltip/tooltip.tcl new/modules/tooltip/tooltip.tcl
--- orig/modules/tooltip/tooltip.tcl	2022-09-26 00:14:05.066762300 +0200
+++ new/modules/tooltip/tooltip.tcl	2022-09-26 00:39:29.998447700 +0200
@@ -226,6 +226,14 @@
 		return -code error "unknown option \"$key\":\
 			should be -index, -item(s), -tab, -tag or --"
 	    }
+	    -heading {
+                if {[winfo class $w] in {Treeview}} {
+                    set heading [lindex $args 1]
+                } else {
+                    return -code error "widget \"$w\" is not a Treeview"
+                }
+		set args [lreplace $args 0 1]
+	    }
 	}
 	set key [lindex $args 0]
     }
@@ -264,6 +272,9 @@
             set tooltip($w,t_$tag) $key
             enableTag $w $tag
             return $w,$tag
+	} elseif {[info exists heading]} {
+		set tooltip($w,$heading) $key
+    enableListbox $w $heading
 	} else {
 	    set tooltip($w) $key
 	    # Note: Add the necessary bindings only once.
@@ -515,7 +526,11 @@
     if {[winfo class $w] eq "Listbox"} {
 	set item [$w index @$x,$y]
     } else {
-	set item [$w identify item $x $y]
+      if {[$w identify region $x $y] eq "heading"} {
+        set item [$w column [$w identify column $x $y] -id]
+      } else {
+        set item [$w identify item $x $y]
+      }
     }
     if {$G(enabled) && [info exists tooltip($w,$item)]} {
 	set G(AFTERID) [after $G(DELAY) \
@@ -536,6 +551,8 @@
 	    set region [$w identify region $x $y]
 	    if {$region  eq "tree" || $region eq "cell"} {
 		set item [$w identify item $x $y]
+	    } elseif {$region eq "heading"} {
+        set item [$w column [$w identify column $x $y] -id]
 	    }
 	}
         if {$item ne $G(LAST)} {