lepetitalbert has asked for the wisdom of the Perl Monks concerning the following question:

Hello dear Monks,

I'm totally unable to bind the up and down keys to move in a tk listbox

I found a few examples but none of them worked.

This is a simple test script :

use Tk; my $mw = MainWindow -> new(); my $lb = $mw -> Scrolled("Listbox", -scrollbars=>'e' , ) -> pack( -side => 'left' , -fill => 'y' ); foreach my $key ("a" , "b" , "c") { $lb -> insert( 'end', $key ); } $lb->activate ( 0 ) ; $lb->selectionSet ( 0 ) ; $lb -> bind ('<Key-Down>', sub {print "haha\n"} ); $mw -> bind ('<Key-Up>', sub {print "\nblabla"} ); MainLoop;

It seems I have to bind the key to the main window and not to the listbox, is this right ?

Thanks for any help or example.

Have a nice day.

"There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates