Am 13.04.22 um 10:39 schrieb Julian H J Loaring:
I find the wcb package to be excellent for handling validation and on change callbacks etc. Today, I noticed that the callback documentation
says:
"...When a callback is invoked, the name of the original Tcl command for the widget widgetName as well as the command arguments are automatically appended to it as parameters..."
=====
package require Tk
package require wcb
package require Ttk
namespace eval gui {
proc build {} {
foreach i {0 1} {
set e [ttk::entry .e$i]
wcb::callback $e before insert gui::meFirst
wcb::callback $e after insert gui::afterYouClaude
grid $e -row 0 -column $i -padx 8 -pady 8
}
}
proc meFirst {w idx string} {
puts "meFirst: $w"
}
proc afterYouClaude {w idx string} {
puts "afterYouClaude: [wcb::pathname $w]"
}
}
gui::build
# meFirst: ::_.e0
# afterYouClaude: .e0
=====
In my experiments, it is the renamed widget command that is passed, not the original Tcl command. Furthermore, this command is namespaced and not a valid Tk widget path so cannot be used in a tk_focusNext $w call for example.
The solution is to use the wcb::pathname function to convert the supplied command back into a widget.
So my suggestion is to change the documentation to read:
"... When a callback is invoked, the name of the proxy command for the Tk widget, and the command arguments, are automatically appended to it as parameters. Use the wcb::pathname command (see below) to retrieve the original Tk widget pathname...."
Many thanks for your excellent packages Csaba, they make life so much easier! kind regards
Julian H J Loaring
You are right that the documentation should be more accurate. I will
improve it for the next Wcb version. Many thanks for your feedback!
Best regards,
Csaba
--
Csaba Nemethi
https://www.nemethi.de mailto:
[email protected]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)