http://www.perlmonks.org?node_id=730015


in reply to Re^2: Dialog box Binding issue
in thread Dialog box Binding issue

That is your issue maybe, it is not a bug in the DialogBox code. It is expected behaviour and it is by design. That is the way all dialogues work in Windows. To activate the control that has focus use the space bar, not the enter key - the enter key always "presses" the default button.


Perl's payment curve coincides with its learning curve.

Replies are listed 'Best First'.
Re^4: Dialog box Binding issue
by Anonymous Monk on Dec 13, 2008 at 13:39 UTC
    Yes it is a bug. I have latest Tk, and I tested, see Re^3: Dialog box Binding issue.

    Try for yourself (tab over to cancel, hit enter).
    Tk::messageBox

    perl -MTk -e"print tkinit->messageBox(qw, -default ok -type okcancel , +)" Cancel
    Tk::MsgBox
    perl -MTk -e"print tkinit->MsgBox(qw, -default ok -type okcancel ,)->S +how" Assuming 'require Tk::MsgBox;' at -e line 1 cancel
    Tk::DialogBox (expected cancel, returns ok)
    perl -MTk -e"print tkinit->DialogBox(qw, -buttons , , [qw, ok cancel , +])->Show" Assuming 'require Tk::DialogBox;' at -e line 1 ok perl -MTk -e"print tkinit->DialogBox(qw, -default_button ok -buttons , + , [qw, ok cancel ,])->Show" Assuming 'require Tk::DialogBox;' at -e line 1 ok
    Changing the default to cancel, then tabbing over selecting ok, and hitting enter, produces cancel, its a bug
    perl -MTk -e"print tkinit->DialogBox(qw, -default_button cancel -butto +ns , , [qw, ok cancel ,])->Show"
    Wx (wxYES is 2, wxNO is 8, and it returns 8 as expected).
    perl -MWx=wxYES,wxNO -e"warn wxYES;warn wxNO; die Wx::MessageBox( 1 , +2, wxYES|wxNO )" 2 at -e line 1. 8 at -e line 1. 8 at -e line 1.