On 06/09/2007, Veli-Pekka Tätilä <[EMAIL PROTECTED]> wrote:
> 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?

I, too, was surprised by this behaviour, but it appears to be
'standard' windows behaviour for radio buttons.  I can't really
explain it, but will describe what I see using Spy++:

Using the mouse:
- Mouse down sets the focus to the button and set the highlight state.
- Mouse up unsets the highlight state and send a BN_CLICKED message to
the parent

Using the keyboard:
- key down causes IsDialogMessage to move the focus to the new button
(which generates a BN_CLICKED message)
- key up causes IsDialogMessage to send a BN_CLICK message to the
button, which in turn causes the button to send itself WM_LBUTTONDOWN
and WM_LBUTTONUP messages (which generates the sequence of events for
the mouse click, which in turn generates the second BN_CLICKED
message)

As I say, I don't really understand the complexity of the message
generation, but I am convinced that this is a windows thing and not a
Win32::GUI bug.

Your click handler needs to cope with multiple clicks anyway, as I can
set there and click the same button again and again ....

Regards,
Rob.


>
> 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ä ([EMAIL PROTECTED])
> Accessibility, game music, synthesizers and programming:
> http://www.student.oulu.fi/~vtatila
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>


-- 
Please update your address book with my new email address:
[EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to