Tk Library Source Code

Check-in [c97cae5b0c]
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ticket [3300362]: add arguments to the msgcat call by options -msgargs and -infoargs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tooltip-plus-image-and-info
Files: files | file ages | folders
SHA3-256: c97cae5b0cb5223f0d4a9ac40df494c664b48dfcc3418cf1e08a7c4a79744493
User & Date: oehhar 2024-05-24 16:25:26
References
2024-05-24
16:30 Closed ticket [3300362fff]: Tooltip font, msgcat namespace plus 8 other changes artifact: 8ebb7e4813 user: oehhar
Context
2024-06-01
12:06
tooltip - tooltip - followup code formatting tweaks, fix of small code typo (error message), and rephrasing docs. regenerated docs Closed-Leaf check-in: e7d8c12b40 user: aku tags: tooltip-plus-image-and-info
2024-05-24
16:25
Ticket [3300362]: add arguments to the msgcat call by options -msgargs and -infoargs check-in: c97cae5b0c user: oehhar tags: tooltip-plus-image-and-info
16:08
Ticket [3300362]: record the caller namespace for msgcat resolution. Add a namespace option to override. Some other option bugs fixed check-in: b145a5c24f user: oehhar tags: tooltip-plus-image-and-info
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/tooltip/tooltip.man.

72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
[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.
The namespace where [cmd ::tooltip::tooltip] is invoked is used to resolve
msgcat, if not overwritten by the [arg -namespace] option.


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]







|
>







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[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.
The namespace where [cmd ::tooltip::tooltip] is invoked is used to resolve
[cmd msgcat::mc], if not overwritten by the [arg -namespace] option.
The format parameters to the [cmd msgcat::mc] call may be given by the options [arg -msgargs] and [args -infoargs] for the message and info part.

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]

Changes to modules/tooltip/tooltip.tcl.

191
192
193
194
195
196
197


198
199
200
201
202
203
204

proc ::tooltip::register {w args} {
    variable tooltip
    set key [lindex $args 0]
    set img {}
    set inf {}
    set nscaller {}


    while {[string match -* $key]} {
	switch -- $key {
	    -- {
		set args [lassign $args _ key]
		break
	    }
	    -heading {







>
>







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

proc ::tooltip::register {w args} {
    variable tooltip
    set key [lindex $args 0]
    set img {}
    set inf {}
    set nscaller {}
    set msgargs {}
    set infoargs {}
    while {[string match -* $key]} {
	switch -- $key {
	    -- {
		set args [lassign $args _ key]
		break
	    }
	    -heading {
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
	    -image {
		set args [lassign $args _ img]
	    }
	    -info {
		set args [lassign $args _ inf]
	    }
	    -namespace {

		set args [lassign $args _ nscaller]
	    }








	    default {
		return -code error "unknown option \"$key\":\
			should be -heading, -image, -index, -info, -item(s), -namespace, -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\""
	}
	if {$nscaller eq ""} {
	    set nscaller [uplevel 2 {namespace current}]
	}
	set details [list $key $img $inf $nscaller]
	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







>


>
>
>
>
>
>
>
>


|
>






|
>











|







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
	    -image {
		set args [lassign $args _ img]
	    }
	    -info {
		set args [lassign $args _ inf]
	    }
	    -namespace {
		# Explicit namespace for the msgcat call
		set args [lassign $args _ nscaller]
	    }
	    -msgargs {
		# Arguments for the msgcat call for the main message
		set args [lassign $args _ msgargs]
	    }
	    -infoargs {
		# Arguments for the msgcat call for the info message
		set args [lassign $args _ infoargs]
	    }
	    default {
		return -code error "unknown option \"$key\":\
			should be -heading, -image, -index, -info, infoargs,\
			-item(s), -msgargs, -namespace, -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?\
		?-infoargs args? ?-item(s) items? ?-msgargs args? ?-namespace ns?\
		?-tab tabId? ?-tag tag? ?--? message\""
    }
    if {$key eq ""} {
	clear $w
    } else {
	if {![winfo exists $w]} {
	    return -code error "bad window path name \"$w\""
	}
	if {$nscaller eq ""} {
	    set nscaller [uplevel 2 {namespace current}]
	}
	set details [list $key $img $inf $nscaller $msgargs $infoargs]
	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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
    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 nscaller
    $b.f.label configure\
	    -text [namespace eval $nscaller [list ::msgcat::mc $txt]]\
	    -image $img
    if {$inf eq {}} {
	grid remove $b.f.info
    } else {
	$b.f.info configure\
		-text [namespace eval $nscaller [list ::msgcat::mc $inf]]
	grid $b.f.info
    }
    update idletasks

    # Bail out if the widget went way during the idletasks
    if {![winfo exists $w]} return








|

|




|
|







454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
    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 nscaller msgargs infoargs
    $b.f.label configure\
	    -text [namespace eval $nscaller [list ::msgcat::mc $txt {*}$msgargs]]\
	    -image $img
    if {$inf eq {}} {
	grid remove $b.f.info
    } else {
	$b.f.info configure -text [namespace eval $nscaller\
		[list ::msgcat::mc $inf {*}$infoargs]]
	grid $b.f.info
    }
    update idletasks

    # Bail out if the widget went way during the idletasks
    if {![winfo exists $w]} return