Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | tooltip - tooltip - ticket [803a13c9f0] <EF> Support images in tooltips, and an additional info field. Supercedes ticket [2970577] and the associated commit [3a592d1145b113c7] (now off trunk and hidden). Bumped version to 1.8. Thanks to Rene Zaumseil for the ticket, patch, and so much patience. Regenerated tooltip documentation (version bump) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tooltip-plus-image-and-info |
Files: | files | file ages | folders |
SHA3-256: |
edc5a0a48fc2e1345ff526461c6e53f7 |
User & Date: | aku 2024-05-23 16:23:06 |
Context
2024-05-23
| ||
16:50 | Fixup of bad conflict resolution. check-in: f848636a5a user: aku tags: tooltip-plus-image-and-info | |
16:23 | tooltip - tooltip - ticket [803a13c9f0] <EF> Support images in tooltips, and an additional info field. Supercedes ticket [2970577] and the associated commit [3a592d1145b113c7] (now off trunk and hidden). Bumped version to 1.8. Thanks to Rene Zaumseil for the ticket, patch, and so much patience. Regenerated tooltip documentation (version bump) check-in: edc5a0a48f user: aku tags: tooltip-plus-image-and-info | |
2024-05-22
| ||
19:52 | tooltip - tooltip - ticket [ff46309014] <B> Bail when widget goes away during an idletasks. Bumped version to 1.7.1. Thank you to Emmanuel Frecon for the ticket and patch. And his patience. Regenerated tooltip documentation (version bump) check-in: c5d09c11fc user: aku tags: trunk | |
Changes
Changes to embedded/md/tklib/files/modules/tooltip/tooltip.md.
1 2 3 4 5 | [//000000001]: # (tooltip \- Tooltip management) [//000000002]: # (Generated from file 'tooltip\.man' by tcllib/doctools with format 'markdown') [//000000003]: # (Copyright © 1996\-2008, Jeffrey Hobbs) [//000000004]: # (Copyright © 2024 Emmanuel Frecon) | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | [//000000001]: # (tooltip \- Tooltip management) [//000000002]: # (Generated from file 'tooltip\.man' by tcllib/doctools with format 'markdown') [//000000003]: # (Copyright © 1996\-2008, Jeffrey Hobbs) [//000000004]: # (Copyright © 2024 Emmanuel Frecon) [//000000005]: # (tooltip\(n\) 1\.8 tklib "Tooltip management") <hr> [ <a href="../../../../toc.md">Main Table Of Contents</a> | <a href="../../../toc.md">Table Of Contents</a> | <a href="../../../../index.md">Keyword Index</a> | <a href="../../../../toc0.md">Categories</a> | <a href="../../../../toc1.md">Modules</a> | <a href="../../../../toc2.md">Applications</a> ] <hr> |
︙ | ︙ | |||
34 35 36 37 38 39 40 | - [Copyright](#copyright) # <a name='synopsis'></a>SYNOPSIS package require Tcl 8\.5 package require msgcat 1\.3 | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | - [Copyright](#copyright) # <a name='synopsis'></a>SYNOPSIS package require Tcl 8\.5 package require msgcat 1\.3 package require tooltip ?1\.8? [__::tooltip::tooltip__ *command* ?*options*?](#1) [__::tooltip::tooltip__ *pathName* ?*option value*\.\.\.? ?__\-\-__? *message*](#2) # <a name='description'></a>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\. |
︙ | ︙ | |||
90 91 92 93 94 95 96 | * __enable__ * __on__ Enables tooltips for defined widgets\. | | | | < | > > > > | | | > > > > > > > > > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | * __enable__ * __on__ Enables tooltips for defined widgets\. - <a name='2'></a>__::tooltip::tooltip__ *pathName* ?*option value*\.\.\.? ?__\-\-__? *message* This command arranges for widget *pathName* to display a tooltip with a *message*\. The tooltip uses late\-binding __msgcat__ calls to allow for on\-the\-fly language changes in an application\. If the widget specified is a __[menu](\.\./\.\./\.\./\.\./index\.md\#menu)__, __[canvas](\.\./\.\./\.\./\.\./index\.md\#canvas)__, __[listbox](\.\./\.\./\.\./\.\./index\.md\#listbox)__, __ttk::treeview__, __ttk::notebook__ or __[text](\.\./\.\./\.\./\.\./index\.md\#text)__ widget then additional options are used to tie the tooltip to specific menu, canvas or listbox items, ttk::treeview items or column headings, ttk::notebook tabs, or text widget tags\. * __\-heading__ *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\. * __\-image__ *image* The specified \(photo\) image will be displayed to the left of the primary tooltip *message*\. * __\-index__ *index* This option is used to set a tooltip on a menu item\. The index may be either the entry index or the entry label\. The widget must be a menu widget but the entries do not have to exist when the tooltip is set\. * __\-info__ *info* The specified *info* text will be displayed as additional information below the primary tooltip *message*\. * __\-items__ *items* This option is used to set a tooltip for canvas, listbox or ttk::treview items\. For the canvas widget, the item must already be present in the canvas and will be found with a __find withtag__ lookup\. For listbox and ttk::treview widgets the item\(s\) may be created later but the programmer is responsible for managing the link between the listbox or |
︙ | ︙ | |||
142 143 144 145 146 147 148 | The __\-tag__ option can be used to set a tooltip for a text widget tag\. The tag should already be present when this command is called, or an error will be returned\. The widget must be a text widget\. * __\-\-__ The __\-\-__ option marks the end of options\. The argument following | | > | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | The __\-tag__ option can be used to set a tooltip for a text widget tag\. The tag should already be present when this command is called, or an error will be returned\. The widget must be a text widget\. * __\-\-__ The __\-\-__ option marks the end of options\. The argument following this one will be treated as *message* even if it starts with a __\-__\. # <a name='section3'></a>EXAMPLE # Demonstrate widget tooltip package require tooltip pack [label .l -text "label"] tooltip::tooltip .l "This is a label widget" |
︙ | ︙ |
Changes to idoc/man/files/modules/tooltip/tooltip.n.
1 2 3 4 5 | '\" '\" Generated from file 'tooltip\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 1996-2008, Jeffrey Hobbs '\" Copyright (c) 2024 Emmanuel Frecon '\" | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | '\" '\" Generated from file 'tooltip\&.man' by tcllib/doctools with format 'nroff' '\" Copyright (c) 1996-2008, Jeffrey Hobbs '\" Copyright (c) 2024 Emmanuel Frecon '\" .TH "tooltip" n 1\&.8 tklib "Tooltip management" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. .\" type is type of argument (int, etc.), in/out is either "in", "out", .\" or "in/out" to describe whether procedure reads or modifies arg, |
︙ | ︙ | |||
275 276 277 278 279 280 281 | .SH NAME tooltip \- Tooltip management .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp package require \fBmsgcat 1\&.3\fR .sp | | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | .SH NAME tooltip \- Tooltip management .SH SYNOPSIS package require \fBTcl 8\&.5\fR .sp package require \fBmsgcat 1\&.3\fR .sp package require \fBtooltip ?1\&.8?\fR .sp \fB::tooltip::tooltip\fR \fIcommand\fR ?\fIoptions\fR? .sp \fB::tooltip::tooltip\fR \fIpathName\fR ?\fIoption value\fR\&.\&.\&.? ?\fB--\fR? \fImessage\fR .sp .BE .SH DESCRIPTION .PP 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\&. |
︙ | ︙ | |||
327 328 329 330 331 332 333 | \fBenable\fR .TP \fBon\fR Enables tooltips for defined widgets\&. .RE .sp .TP | | | | | | | > > > > > > > > | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | \fBenable\fR .TP \fBon\fR Enables tooltips for defined widgets\&. .RE .sp .TP \fB::tooltip::tooltip\fR \fIpathName\fR ?\fIoption value\fR\&.\&.\&.? ?\fB--\fR? \fImessage\fR This command arranges for widget \fIpathName\fR to display a tooltip with a \fImessage\fR\&. The tooltip uses late-binding \fBmsgcat\fR calls to allow for on-the-fly language changes in an application\&. If the widget specified is a \fBmenu\fR, \fBcanvas\fR, \fBlistbox\fR, \fBttk::treeview\fR, \fBttk::notebook\fR or \fBtext\fR widget then additional options are used to tie the tooltip to specific menu, canvas or listbox items, ttk::treeview items or column headings, ttk::notebook tabs, or text widget tags\&. .RS .TP \fB-heading\fR \fIcolumnId\fR 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\&. .TP \fB-image\fR \fIimage\fR The specified (photo) image will be displayed to the left of the primary tooltip \fImessage\fR\&. .TP \fB-index\fR \fIindex\fR This option is used to set a tooltip on a menu item\&. The index may be either the entry index or the entry label\&. The widget must be a menu widget but the entries do not have to exist when the tooltip is set\&. .TP \fB-info\fR \fIinfo\fR The specified \fIinfo\fR text will be displayed as additional information below the primary tooltip \fImessage\fR\&. .TP \fB-items\fR \fIitems\fR This option is used to set a tooltip for canvas, listbox or ttk::treview items\&. For the canvas widget, the item must already be present in the canvas and will be found with a \fBfind withtag\fR lookup\&. For listbox and ttk::treview widgets the item(s) may be created later but the programmer is responsible for managing the link between the listbox or ttk::treview item index and the corresponding tooltip\&. If the listbox or |
︙ | ︙ | |||
372 373 374 375 376 377 378 | The \fB-tag\fR option can be used to set a tooltip for a text widget tag\&. The tag should already be present when this command is called, or an error will be returned\&. The widget must be a text widget\&. .TP \fB--\fR The \fB--\fR option marks the end of options\&. The argument following this one will be treated as \fImessage\fR even if it | | | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | The \fB-tag\fR option can be used to set a tooltip for a text widget tag\&. The tag should already be present when this command is called, or an error will be returned\&. The widget must be a text widget\&. .TP \fB--\fR The \fB--\fR option marks the end of options\&. The argument following this one will be treated as \fImessage\fR even if it starts with a \fB-\fR\&. .RE .PP .SH EXAMPLE .CS # Demonstrate widget tooltip |
︙ | ︙ |
Changes to idoc/www/tklib/files/modules/tooltip/tooltip.html.
︙ | ︙ | |||
103 104 105 106 107 108 109 | | <a href="../../../toc.html">Table Of Contents</a> | <a href="../../../../index.html">Keyword Index</a> | <a href="../../../../toc0.html">Categories</a> | <a href="../../../../toc1.html">Modules</a> | <a href="../../../../toc2.html">Applications</a> ] <hr> <div class="doctools"> | | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | | <a href="../../../toc.html">Table Of Contents</a> | <a href="../../../../index.html">Keyword Index</a> | <a href="../../../../toc0.html">Categories</a> | <a href="../../../../toc1.html">Modules</a> | <a href="../../../../toc2.html">Applications</a> ] <hr> <div class="doctools"> <h1 class="doctools_title">tooltip(n) 1.8 tklib "Tooltip management"</h1> <div id="name" class="doctools_section"><h2><a name="name">Name</a></h2> <p>tooltip - Tooltip management</p> </div> <div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2> <ul class="doctools_toc"> <li class="doctools_section"><a href="#toc">Table Of Contents</a></li> <li class="doctools_section"><a href="#synopsis">Synopsis</a></li> <li class="doctools_section"><a href="#section1">Description</a></li> <li class="doctools_section"><a href="#section2">COMMANDS</a></li> <li class="doctools_section"><a href="#section3">EXAMPLE</a></li> <li class="doctools_section"><a href="#section4">Bugs, Ideas, Feedback</a></li> <li class="doctools_section"><a href="#keywords">Keywords</a></li> <li class="doctools_section"><a href="#copyright">Copyright</a></li> </ul> </div> <div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2> <div class="doctools_synopsis"> <ul class="doctools_requirements"> <li>package require <b class="pkgname">Tcl 8.5</b></li> <li>package require <b class="pkgname">msgcat 1.3</b></li> <li>package require <b class="pkgname">tooltip <span class="opt">?1.8?</span></b></li> </ul> <ul class="doctools_syntax"> <li><a href="#1"><b class="cmd">::tooltip::tooltip</b> <i class="arg">command</i> <span class="opt">?<i class="arg">options</i>?</span></a></li> <li><a href="#2"><b class="cmd">::tooltip::tooltip</b> <i class="arg">pathName</i> <span class="opt">?<i class="arg">option value</i>...?</span> <span class="opt">?<b class="const">--</b>?</span> <i class="arg">message</i></a></li> </ul> </div> </div> <div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2> <p>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.</p> |
︙ | ︙ | |||
169 170 171 172 173 174 175 | <dt><b class="option">off</b></dt> <dd><p>Disable all tooltips</p></dd> <dt><b class="option">enable</b></dt> <dd></dd> <dt><b class="option">on</b></dt> <dd><p>Enables tooltips for defined widgets.</p></dd> </dl></dd> | | | | | | | > > > > > > | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | <dt><b class="option">off</b></dt> <dd><p>Disable all tooltips</p></dd> <dt><b class="option">enable</b></dt> <dd></dd> <dt><b class="option">on</b></dt> <dd><p>Enables tooltips for defined widgets.</p></dd> </dl></dd> <dt><a name="2"><b class="cmd">::tooltip::tooltip</b> <i class="arg">pathName</i> <span class="opt">?<i class="arg">option value</i>...?</span> <span class="opt">?<b class="const">--</b>?</span> <i class="arg">message</i></a></dt> <dd><p>This command arranges for widget <i class="arg">pathName</i> to display a tooltip with a <i class="arg">message</i>. The tooltip uses late-binding <b class="package">msgcat</b> calls to allow for on-the-fly language changes in an application. If the widget specified is a <b class="cmd"><a href="../../../../index.html#menu">menu</a></b>, <b class="cmd"><a href="../../../../index.html#canvas">canvas</a></b>, <b class="cmd"><a href="../../../../index.html#listbox">listbox</a></b>, <b class="cmd">ttk::treeview</b>, <b class="cmd">ttk::notebook</b> or <b class="cmd"><a href="../../../../index.html#text">text</a></b> widget then additional options are used to tie the tooltip to specific menu, canvas or listbox items, ttk::treeview items or column headings, ttk::notebook tabs, or text widget tags.</p> <dl class="doctools_options"> <dt><b class="option">-heading</b> <i class="arg">columnId</i></dt> <dd><p>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.</p></dd> <dt><b class="option">-image</b> <i class="arg">image</i></dt> <dd><p>The specified (photo) image will be displayed to the left of the primary tooltip <i class="arg">message</i>.</p></dd> <dt><b class="option">-index</b> <i class="arg">index</i></dt> <dd><p>This option is used to set a tooltip on a menu item. The index may be either the entry index or the entry label. The widget must be a menu widget but the entries do not have to exist when the tooltip is set.</p></dd> <dt><b class="option">-info</b> <i class="arg">info</i></dt> <dd><p>The specified <i class="arg">info</i> text will be displayed as additional information below the primary tooltip <i class="arg">message</i>.</p></dd> <dt><b class="option">-items</b> <i class="arg">items</i></dt> <dd><p>This option is used to set a tooltip for canvas, listbox or ttk::treview items. For the canvas widget, the item must already be present in the canvas and will be found with a <b class="cmd">find withtag</b> lookup. For listbox and ttk::treview widgets the item(s) may be created later but the programmer is responsible for managing the link between the listbox or ttk::treview item index and the corresponding tooltip. If the listbox or ttk::treview items are re-ordered, the tooltips will need amending.</p> <p>If the widget is not a canvas, listbox or ttk::treview then an error is raised.</p></dd> <dt><b class="option">-tab</b> <i class="arg">tabId</i></dt> <dd><p>The <b class="option">-tab</b> option can be used to set a tooltip for a ttk::notebook tab. The tab should already be present when this command is called, or an error will be returned. The widget must be a ttk::notebook widget.</p></dd> <dt><b class="option">-tag</b> <i class="arg">name</i></dt> <dd><p>The <b class="option">-tag</b> option can be used to set a tooltip for a text widget tag. The tag should already be present when this command is called, or an error will be returned. The widget must be a text widget.</p></dd> <dt><b class="option">--</b></dt> <dd><p>The <b class="option">--</b> option marks the end of options. The argument following this one will be treated as <i class="arg">message</i> even if it starts with a <b class="const">-</b>.</p></dd> </dl></dd> </dl> </div> <div id="section3" class="doctools_section"><h2><a name="section3">EXAMPLE</a></h2> <pre class="doctools_example"> # Demonstrate widget tooltip package require tooltip |
︙ | ︙ |
Changes to modules/tooltip/ChangeLog.
1 2 3 4 5 6 7 | 2024-05-22 Andreas Kupries <[email protected]> * Bumped to version 1.7.1. Bail if widget goes away during early idletasks in `show`. Ticket [https://core.tcl-lang.org/tklib/tktview/ff46309014]. Patch by Emmanuel Frecon. 2024-05-05 Csaba Nemethi <[email protected]> | > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | 2024-05-23 Andreas Kupries <[email protected]> * Bumped to version 1.8. Support images and additional info text. Ticket [https://core.tcl-lang.org/tklib/tktview/803a13c9f0]. Patch by Rene Zaumseil. 2024-05-22 Andreas Kupries <[email protected]> * Bumped to version 1.7.1. Bail if widget goes away during early idletasks in `show`. Ticket [https://core.tcl-lang.org/tklib/tktview/ff46309014]. Patch by Emmanuel Frecon. 2024-05-05 Csaba Nemethi <[email protected]> |
︙ | ︙ |
Changes to modules/tooltip/tooltip.man.
1 | [comment {-*- tcl -*- doctools manpage}] | | | 1 2 3 4 5 6 7 8 9 | [comment {-*- tcl -*- doctools manpage}] [vset VERSION 1.8] [manpage_begin tooltip n [vset VERSION]] [keywords balloon] [keywords help] [keywords hover] [keywords tooltip] [copyright {1996-2008, Jeffrey Hobbs}] [copyright {2024 Emmanuel Frecon}] |
︙ | ︙ | |||
65 66 67 68 69 70 71 | Enables tooltips for defined widgets. [list_end] [para] | | | | | | > | | > > > > > > > > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | Enables tooltips for defined widgets. [list_end] [para] [call [cmd ::tooltip::tooltip] [arg pathName] [opt [arg "option value"]...] \ [opt [const --]] [arg message]] This command arranges for widget [arg pathName] to display a tooltip with a [arg message]. The tooltip uses late-binding [package msgcat] calls to allow for on-the-fly language changes in an application. If the widget specified is a [cmd menu], [cmd canvas], [cmd listbox], [cmd ttk::treeview], [cmd ttk::notebook] or [cmd text] widget then additional options are used to tie the tooltip to specific menu, canvas or listbox items, ttk::treeview items or column headings, ttk::notebook tabs, or text widget tags. [list_begin options] [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 -image [arg image]] The specified (photo) image will be displayed to the left of the primary tooltip [arg message]. [opt_def -index [arg index]] This option is used to set a tooltip on a menu item. The index may be either the entry index or the entry label. The widget must be a menu widget but the entries do not have to exist when the tooltip is set. [opt_def -info [arg info]] The specified [arg info] text will be displayed as additional information below the primary tooltip [arg message]. [opt_def -items [arg items]] This option is used to set a tooltip for canvas, listbox or ttk::treview items. For the canvas widget, the item must already be present in the canvas and will be found with a [cmd "find withtag"] lookup. For listbox and ttk::treview widgets the item(s) may be created later but the |
︙ | ︙ | |||
118 119 120 121 122 123 124 125 | The [option -tag] option can be used to set a tooltip for a text widget tag. 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 --] The [option --] option marks the end of options. The argument following this one will be treated as [arg message] even if it | > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | The [option -tag] option can be used to set a tooltip for a text widget tag. 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 --] The [option --] option marks the end of options. The argument following this one will be treated as [arg message] even if it starts with a [const -]. [list_end] [list_end] [section EXAMPLE] |
︙ | ︙ |
Changes to modules/tooltip/tooltip.tcl.
1 2 3 4 5 | # tooltip.tcl -- # # Balloon help # # Copyright (c) 1996-2007 Jeffrey Hobbs | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # tooltip.tcl -- # # Balloon help # # Copyright (c) 1996-2007 Jeffrey Hobbs # Copyright (c) 2024 Emmanuel Frecon, Rene Zaumseil # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # Initiated: 28 October 1996 package require Tk 8.6- package require msgcat #------------------------------------------------------------------------ # PROCEDURE # tooltip::tooltip # # DESCRIPTION |
︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | # # EXAMPLE USAGE: # tooltip .button "A Button" # tooltip .menu -index "Load" "Loads a file" # #------------------------------------------------------------------------ namespace eval ::tooltip { namespace export -clear tooltip variable tooltip variable G if {![info exists G]} { array set G { | > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # # EXAMPLE USAGE: # tooltip .button "A Button" # tooltip .menu -index "Load" "Loads a file" # #------------------------------------------------------------------------ # TkTooltipFont is defined in tk library/ttk/fonts.tcl catch {font create TkTooltipFontItalic} catch {font configure TkTooltipFontItalic \ {*}[font configure TkTooltipFont] -slant italic} namespace eval ::tooltip { namespace export -clear tooltip variable tooltip variable G if {![info exists G]} { array set G { |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | option add *Tooltip.Label.borderWidth 1 option add *Tooltip.Label.padX 5 option add *Tooltip.Label.padY 5 # configurable options option add *Tooltip.Label.background lightyellow option add *Tooltip.Label.foreground black option add *Tooltip.Label.font TkTooltipFont # The extra ::hide call in <Enter> is necessary to catch moving to # child widgets where the <Leave> event won't be generated bind Tooltip <Enter> [namespace code { #tooltip::hide variable tooltip variable G | > > > > > > > > > > > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | option add *Tooltip.Label.borderWidth 1 option add *Tooltip.Label.padX 5 option add *Tooltip.Label.padY 5 # configurable options option add *Tooltip.Label.background lightyellow option add *Tooltip.Label.foreground black option add *Tooltip.Label.font TkTooltipFont option add *Tooltip.Frame.highlightThickness 0 option add *Tooltip.Frame.relief solid option add *Tooltip.Frame.borderWidth 1 option add *Tooltip.Frame.background lightyellow option add *Tooltip.Info.borderWidth 0 option add *Tooltip.Info.background lightyellow option add *Tooltip.Info.foreground black option add *Tooltip.Info.font TkTooltipFontItalic option add *Tooltip.Info.padX 3 option add *Tooltip.Info.padY 3 # The extra ::hide call in <Enter> is necessary to catch moving to # child widgets where the <Leave> event won't be generated bind Tooltip <Enter> [namespace code { #tooltip::hide variable tooltip variable G |
︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 | } } } proc ::tooltip::register {w args} { variable tooltip set key [lindex $args 0] while {[string match -* $key]} { switch -- $key { -- { | > > | < | | < < | | > > < | | | > | > < | < | | > > < | > | > > > | | > > > | | > | | | | | | < | > > > | > > > > | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | } } } proc ::tooltip::register {w args} { variable tooltip set key [lindex $args 0] set img {} set inf {} while {[string match -* $key]} { switch -- $key { -- { set args [lassign $args _ key] break } -heading { if {[winfo class $w] ne "Treeview"} { return -code error "widget \"$w\" is not a ttk::treeview widget" } set args [lassign $args _ columnId] } -index { if {[catch { $w entrycget 1 -label }]} { return -code error "widget \"$w\" does not seem to be a\ menu, which is required for the -index switch" } set args [lassign $args _ index] } -item - -items { if {[winfo class $w] in {Listbox Treeview}} { set args [lassign $args _ items] } else { set args [lassign $args _ namedItem] if {[catch { $w find withtag $namedItem } items]} { return -code error "widget \"$w\" is not a canvas, or\ item \"$namedItem\" does not exist in the canvas" } } } -tab { if {[winfo class $w] ne "TNotebook"} { return -code error "widget \"$w\" is not a ttk::notebook widget" } set args [lassign $args _ tabId] if {[catch { $w index $tabId } tabIndex]} { return -code error $tabIndex } elseif {$tabIndex < 0 || $tabIndex >= [$w index end]} { return -code error "tab index $tabId out of bounds" } set tabWin [lindex [$w tabs] $tabIndex] } -tag { set args [lassign $args _ tag] set r [catch { lsearch -exact [$w tag names] $tag } ndx] if {$r || $ndx == -1} { return -code error "widget \"$w\" is not a text widget or\ \"$tag\" is not a text tag" } } -image { set args [lassign $args img] } -info { set args [lassign $args inf] } default { return -code error "unknown option \"$key\":\ should be -heading, -image, -index, -info, -item(s), -tab, -tag or --" } } set key [lindex $args 0] } if {[llength $args] != 1} { return -code error "wrong # args: should be \"tooltip widget\ ?-heading columnId? ?-image image? ?-index index? ?-info info? ?-item(s) items?\ ?-tab tabId? ?-tag tag? ?--? message\"" } if {$key eq ""} { clear $w } else { if {![winfo exists $w]} { return -code error "bad window path name \"$w\"" } set details [list $key $img $inf] if {[info exists columnId]} { set tooltip($w,$columnId) $details enableListbox $w $columnId return $w,$columnId } elseif {[info exists index]} { set tooltip($w,$index) $details return $w,$index } elseif {[info exists items]} { foreach item $items { set tooltip($w,$item) $details set class [winfo class $w] if { $class eq "Listbox" || $class eq "Treeview"} { enableListbox $w $item } else { enableCanvas $w $item } } # Only need to return the first item for the purposes of # how this is called return $w,[lindex $items 0] } elseif {[info exists tabWin]} { set tooltip($w,$tabWin) $details enableNotebook $w $tabWin return $w,$tabWin } elseif {[info exists tag]} { set tooltip($w,t_$tag) $details enableTag $w $tag return $w,$tag } else { set tooltip($w) $details # Note: Add the necessary bindings only once. set tags [bindtags $w] if {[lsearch -exact $tags "Tooltip"] == -1} { bindtags $w [linsert $tags end "Tooltip"] } return $w } } } proc ::tooltip::createToplevel {} { variable G set b $G(TOPLEVEL) if {[winfo exists $b]} { return } toplevel $b -class Tooltip -borderwidth 0 if {[tk windowingsystem] eq "aqua"} { ::tk::unsupported::MacWindowStyle style $b help none } else { wm overrideredirect $b 1 } catch {wm attributes $b -topmost 1} # avoid the blink issue with 1 to <1 alpha on Windows catch {wm attributes $b -alpha 0.99} wm positionfrom $b program wm withdraw $b frame $b.f label $b.f.label -justify left -compound left label $b.f.info -justify left grid $b.f grid $b.f.label -sticky w grid $b.f.info -sticky w grid columnconfigure $b.f 1 -weight 1 } proc ::tooltip::configure {args} { set len [llength $args] if {$len >= 2 && ($len % 2) != 0} { return -level 2 -code error "wrong # args. Should be\ \"tooltip configure ?opt ?val opt val ...??\"" |
︙ | ︙ | |||
368 369 370 371 372 373 374 | variable tooltip # cache the current widget at pointer set ptrw [winfo containing {*}[winfo pointerxy .]] foreach w [array names tooltip $pattern] { unset tooltip($w) if {[winfo exists $w]} { set tags [bindtags $w] | | > | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | variable tooltip # cache the current widget at pointer set ptrw [winfo containing {*}[winfo pointerxy .]] foreach w [array names tooltip $pattern] { unset tooltip($w) if {[winfo exists $w]} { set tags [bindtags $w] set i [lsearch -exact $tags "Tooltip"] if {$i != -1} { bindtags $w [lreplace $tags $i $i] } ## We don't remove TooltipMenu because there ## might be other indices that use it # Withdraw the tooltip if we clear the current contained item if {$ptrw eq $w} { hide } |
︙ | ︙ | |||
399 400 401 402 403 404 405 406 407 408 409 410 | after cancel $G(FADEID) set b $G(TOPLEVEL) if {![winfo exists $b]} { createToplevel } # 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 update idletasks # Bail out if the widget went way during the idletasks if {![winfo exists $w]} return | > > > > > > > > > | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | after cancel $G(FADEID) set b $G(TOPLEVEL) if {![winfo exists $b]} { createToplevel } # Use late-binding msgcat (lazy translation) to support programs # that allow on-the-fly l10n changes lassign $msg txt img inf $b.f.label configure -text [::msgcat::mc $txt] -image $img if {$inf eq {}} { grid remove $b.f.info } else { $b.f.info configure -text [::msgcat::mc $inf] grid $b.f.info } $b.label configure -text [::msgcat::mc $msg] -justify left update idletasks # Bail out if the widget went way during the idletasks if {![winfo exists $w]} return set screenw [winfo screenwidth $w] set screenh [winfo screenheight $w] set reqw [winfo reqwidth $b] set reqh [winfo reqheight $b] # When adjusting for being on the screen boundary, check that we are # near the "edge" already, as Tk handles multiple monitors oddly if {$i eq "cursor"} { |
︙ | ︙ | |||
477 478 479 480 481 482 483 | # <<MenuSelect>> event is properly coded for Unix/(Windows)? if {$cur == $G(LAST)} return set G(LAST) $cur # a little inlining - this is :hide after cancel $G(AFTERID) catch {wm withdraw $G(TOPLEVEL)} if {[info exists tooltip($m,$cur)] || \ | > | > > > | | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | # <<MenuSelect>> event is properly coded for Unix/(Windows)? if {$cur == $G(LAST)} return set G(LAST) $cur # a little inlining - this is :hide after cancel $G(AFTERID) catch {wm withdraw $G(TOPLEVEL)} if {[info exists tooltip($m,$cur)] || \ (![catch { $w entrycget $cur -label } cur] && \ [info exists tooltip($m,$cur)])} { set G(AFTERID) [after $G(DELAY) \ [namespace code [list show $w $tooltip($m,$cur) cursor]]] } } } proc ::tooltip::hide {{fadeOk 0}} { variable G after cancel $G(AFTERID) after cancel $G(FADEID) if {$fadeOk && $G(fade)} { fade $G(TOPLEVEL) $G(FADESTEP) } else { catch {wm withdraw $G(TOPLEVEL)} } } proc ::tooltip::fade {w step} { if {[catch { wm attributes $w -alpha } alpha] || $alpha <= 0.0} { catch { wm withdraw $w } catch { wm attributes $w -alpha 0.99 } } else { variable G wm attributes $w -alpha [expr {$alpha-$step}] set G(FADEID) [after 50 [namespace code [list fade $w $step]]] } |
︙ | ︙ | |||
663 664 665 666 667 668 669 | if {[string match *tagTip* [$w tag bind $tag]]} { return } $w tag bind $tag <Enter> +[namespace code [list tagTip $w $tag]] $w tag bind $tag <Leave> +[namespace code [list hide 1]] ; # fade ok $w tag bind $tag <Any-KeyPress> +[namespace code hide] $w tag bind $tag <Any-Button> +[namespace code hide] } | | | 710 711 712 713 714 715 716 717 | if {[string match *tagTip* [$w tag bind $tag]]} { return } $w tag bind $tag <Enter> +[namespace code [list tagTip $w $tag]] $w tag bind $tag <Leave> +[namespace code [list hide 1]] ; # fade ok $w tag bind $tag <Any-KeyPress> +[namespace code hide] $w tag bind $tag <Any-Button> +[namespace code hide] } package provide tooltip 1.8 |