Sujet : Re: How to pass an object from inside its own method to a helper function
De : nospam (at) *nospam* wanadoo.nl (Schelte)
Groupes : comp.lang.tclDate : 11. Jul 2024, 12:12:52
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$51f688df$79eeaed5@f984d21cd0a14d8f>
References : 1 2
User-Agent : Mozilla Thunderbird
On 11/07/2024 12:03, Mark Summerfield wrote:
I worked out how to do it:
proc make_file_menu {app} {
.menu.file add command -command [list ${app}::my on_quit] \
-label Quit -underline 0 -accelerator Ctrl+Q
}
Or less hacky:
proc make_file_menu {app} {
.menu.file add command -command [list $app on_quit] \
-label Quit -underline 0 -accelerator Ctrl+Q
}
Originally you had $app inside curly braces, which prevented it from being substituted at definition time. At execution time, the app variable was out of scope.
Schelte.