On Wednesday, June 27, 2018 at 6:44:05 AM UTC-7, Cecil Westerhof wrote:
> I am interested in the current selection. At the moment I use:
> bind .brew <<ListboxSelect>> [list makeTea .brew]
>
> and:
> proc makeTea {nb} {
> puts "Entering makeTea"
> puts [${nb} get [${nb} curselection]]
> puts "Leaving makeTea"
> }
>
> But I would expect it to be possible in the bind. Am I overlooking
> something?
>
> Also: do you need the two steps I use to get the current selection?
bind itself has no knowledge of the listbox's current selection.
bind only has knowledge of the event and possibly a few parameters
associted with the event.
In this case, <<ListboxSelection>> is a virtual event, and there are no
parameters for bind to access.
Also, once the bind script becomes more than very simple, it is better
to put the code into a procedure so that the procedure is byte-compiled.
A bind script (i.e. the script directly attached to the bind command) is not byte-compiled.