This causes the callback handler to determine screen coordinates from the on-screen location and height of the widget specified by the -widget option.
Compare:
$abut configure -onClicked "$menu popup -widget %w"
With:
$abut configure -data $menu -onClicked {
lassign [gnocl::winfo geometry %w] x y w h
%d popup [expr $x-4] [expr $y+$h] }
This latter approach not only requires memory allocation using -data but 'pollutes' the global namespace with the extra variables 'x y w h' which might result in some form of conflict.
For those who notice, there is '+4' which is an attempt to handle the buttons style border-width setting. This isn't handled in the callback script, but accommodated in the module core.

No comments:
Post a Comment