The code
my $pv = new pvoicecommon(
program_title => "pVoice 0.02.1 development",
bgcolor => 'white',
active_bgcolor => 'red',
sounddir => "./data",
current_category=> "",
current_page => 1,
indexfile => "index.txt",
catfile => "cat.txt",
sound_ext => "wav",
img_ext => "jpg",
border_width => 10,
cellpadding => 4,
columns => 4,
rows => 4,
selected_button => 0
);
$pv->mainframe($main->Frame(-background => $pv->bgcolor())->pack());
Binding the mouseclicks
Not the click on the button creates the invocation, but clicks on the background of the $main window:
# Right mouseclick means select next item
$main->bind('',
sub {
$pv->buttons()->[$pv->selected_button()]->configure(
-state => 'normal');
if ($pv->selected_button() < @{$pv->buttons()} -1)
{$pv->selected_button($pv->selected_button()+1)}
else {$pv->selected_button(0)}
$pv->buttons()->[$pv->selected_button()]->configure(
-state => 'active');
}
);
# Left mouseclick means execute current item
$main->bind('',
sub {
$pv->buttons()->[$pv->selected_button()]->invoke();
}
);
Next