Tk Library Source Code

Artifact [3454c9be3f]
Login

Artifact 3454c9be3ff82b2adf76ba1399001842bb781885:

Attachment "tooltip.diff" to ticket [2970577fff] added by r_zaumseil 2010-03-16 20:35:49.
--- tooltip.tcl	2008-12-02 00:37:16.000000000 +0100
+++ tooltip.tcl	2010-03-16 12:14:34.000000000 +0100
@@ -38,7 +38,7 @@ package require msgcat
 # enable OR on
 #	Enables tooltips for defined widgets.
 #
-# <widget> ?-index index? ?-items id? ?-tag tag? ?message?
+# <widget> ?-index index? ?-items id? ?-tag tag? ?message|image?
 #	If -index is specified, then <widget> is assumed to be a menu
 #	and the index represents what index into the menu (either the
 #	numerical index or the label) to associate the tooltip message with.
@@ -214,7 +214,7 @@ proc ::tooltip::register {w args} {
     }
     if {[llength $args] != 1} {
 	return -code error "wrong # args: should be \"tooltip widget\
-		?-index index? ?-items item? ?-tag tag? message\""
+		?-index index? ?-items item? ?-tag tag? message|image\""
     }
     if {$key eq ""} {
 	clear $w
@@ -286,7 +286,13 @@ proc ::tooltip::show {w msg {i {}}} {
     set b $G(TOPLEVEL)
     # Use late-binding msgcat (lazy translation) to support programs
     # that allow on-the-fly l10n changes
-    $b.label configure -text [::msgcat::mc $msg] -justify left
+    if {[catch {set type [image type $msg]}]} {
+      $b.label configure -text [::msgcat::mc $msg] -bitmap {} -image {} -justify left
+    } elseif {$type eq {bitmap}} {
+      $b.label configure -text {} -bitmap $msg -image {} -justify left
+    } else {
+      $b.label configure -text {} -bitmap {} -image $msg -justify left
+    }
     update idletasks
     set screenw [winfo screenwidth $w]
     set screenh [winfo screenheight $w]