From: Veli-Pekka <vt...@ma...> - 2007-09-06 17:56:32
|
Hi list, I think I might have found a bug in the event handling of Radio Buttons, or else have just somehow misunderstood how their event handling works. EIther way, I'd appreciate any comments and clarifications. Issue: if I create two radio buttons in a dialog, set them up in the tab order, and then use the arrows to select one of the buttons, the onClick event is fired twice when the arrows are used to select another radio button. In contrast, if I use the mouse or click the button programmatically, the event is fired only once. I would have expected the latter behavior in keyboard usage, too. What causes the refiring of the onClick event? version info: This is perl, v5.8.8 built for MSWin32-x86-multi-thread Documentation for Win32::GUI v1.05 created 05 Nov 2006 Sample code: use strict; use warnings; use Win32::GUI qw||; use Win32::GUI::GridLayout; my($width, $height) = qw|4 4|; my $win = Win32::GUI::DialogBox->new ( -name => 'win', -size => [40 * $width, 40 * $height], -text => 'radios' -onTerminate => sub { -1 }, ); my $grid = Win32::GUI::GridLayout->apply ( $win, $width, $height, 0, 0 ); my @buttons; for my $i (1 .. $width) { # Ad some radio buttons. my $radio = Win32::GUI::RadioButton->new ( $win, -name => "b$i", -tabstop => 1 , -text => $i, -onClick => sub { print "Click ", (shift)->UserData() . "\n"; 1 } ); $radio->UserData($i); $grid->add($radio, $i, $height / 2); push @buttons, $radio; } # for my $first = $buttons[0]; $first->SetFocus(); $first->Click(); $grid->recalc(); $win->Show(); Win32::GUI::Dialog(); -- With kind regards Veli-Pekka Tätilä (vt...@ma...) Accessibility, game music, synthesizers and programming: http://www.student.oulu.fi/~vtatila |