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

Hi, my issue is when i want to select 'No' Button, i press a Tab button and now the focus will be on No and press Return Key even in that case "YES" is selected :(

Replies are listed 'Best First'.
Re^3: Dialog box Binding issue
by GrandFather (Saint) on Dec 12, 2008 at 18:41 UTC

    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.
      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.
Re^3: Dialog box Binding issue
by Anonymous Monk on Dec 12, 2008 at 14:29 UTC
    This is a bug in Tk::DialogBox, you should report it here. To test run widget, under "Common Dialogs" click on "1. Message boxes.", when "messageBox Demo" pops up, choose Type OkCancel, then click "Message Box" button, and perform the test (tab over to cancel button, hit enter). Default is "Tk::DialogBox", and selecting Cancel and hitting enter doesn't work (falsely returns that you selected Ok). If you click radio button to switch to Tk::MsgBox , and perform test again, you will get Cancel as expected.