Tk Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

tooltip - Tooltip management

Table Of Contents

SYNOPSIS

package require Tcl 8.5
package require tooltip ?2.0.1?

::tooltip::tooltip command ?options?
::tooltip::tooltip pathName ?option value...? ?--? message

DESCRIPTION

This package provides tooltips, i.e., small text messages that can be displayed when the mouse hovers over a widget, menu item, canvas item, listbox item, ttk::treeview item or column heading, ttk::notebook tab, or text widget tag.

COMMANDS

EXAMPLE

# Demonstrate widget tooltip
package require tooltip
pack [label .l -text "label"]
tooltip::tooltip .l "This is a label widget"

# Demonstrate menu tooltip
package require tooltip
. configure -menu [menu .menu]
.menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
.menu.test add command -label Tooltip
tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"

# Demonstrate canvas item tooltip
package require tooltip
pack [canvas .c]
set item [.c create rectangle 10 10 80 80 -fill red]
tooltip::tooltip .c -item $item "Canvas item tooltip"

# Demonstrate listbox item tooltip
package require tooltip
pack [listbox .lb]
.lb insert 0 "item one"
tooltip::tooltip .lb -item 0 "Listbox item tooltip"

# Demonstrate ttk::notebook tab tooltip
package require tooltip
pack [ttk::notebook .nb]
.nb add [frame .nb.f1 -height 50] -text "First tab"
.nb add [frame .nb.f2 -height 50] -text "Second tab"
tooltip::tooltip .nb -tab 0 "Tooltip for the 1st notebook tab"
tooltip::tooltip .nb -tab 1 "Tooltip for the 2nd notebook tab"

# Demonstrate text tag tooltip
package require tooltip
pack [text .txt]
.txt tag configure TIP-1 -underline 1
tooltip::tooltip .txt -tag TIP-1 "tooltip one text"
.txt insert end "An example of a " {} "tooltip" TIP-1 " tag.\n" {}

Migration from Version 1

Version 1.3 to 1.7 called msgcat::mc before a tooltip was shown, using the tooltip namespace. msgcat::mc requires the caller environment. Due to that, version 1.8 recorded the caller namespace and used this in the call. In version 2.0, any msgcat::mc support was removed. The options -namespace, -msgargs and -infoargs were removed. Starting with TCL 8.7, msgcat::mc supports oo classes and oo methods. But the oo caller environment is not present when the msgcat::mc was invoked on tooltip display, resulting in runtime errors. It was concluded as bad design to call msgcat::mc late. The caller should reinstall the tooltips on eventual message change.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tooltip of the Tklib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

KEYWORDS

balloon, help, hover, tooltip

COPYRIGHT

Copyright © 1996-2008, Jeffrey Hobbs
Copyright © 2024 Emmanuel Frecon