Don't handle "Return" key as "TAB" even when the default button is disabled.
wxMSW used to handle VK_RETURN in the same way as VK_TAB if it wasn't consumed by the default push button but this didn't correspond to the native platform behaviour which considers pressing Return when the OK button is disabled an error and audibly notifies the user about it. Fix this by passing VK_RETURN to IsDialogMessage() if we don't translate it to a button click. Also add a possibility to test what happens when the default (or all) button(s) in the dialog are disabled to the dialogs sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1769,10 +1769,15 @@ void MyFrame::OnStandardButtonsSizerDialog(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
#define ID_CATCH_LISTBOX_DCLICK 100
|
||||
#define ID_LISTBOX 101
|
||||
#define ID_DISABLE_OK 102
|
||||
#define ID_DISABLE_CANCEL 103
|
||||
|
||||
BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
|
||||
EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK, TestDefaultActionDialog::OnCatchListBoxDClick)
|
||||
EVT_CHECKBOX(ID_DISABLE_OK, TestDefaultActionDialog::OnDisableOK)
|
||||
EVT_CHECKBOX(ID_DISABLE_CANCEL, TestDefaultActionDialog::OnDisableCancel)
|
||||
EVT_LISTBOX_DCLICK(ID_LISTBOX, TestDefaultActionDialog::OnListBoxDClick)
|
||||
EVT_TEXT_ENTER(wxID_ANY, TestDefaultActionDialog::OnTextEnter)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
||||
@@ -1801,6 +1806,9 @@ TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
||||
grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), wxTE_PROCESS_ENTER ), 0, wxALIGN_CENTRE_VERTICAL );
|
||||
grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
|
||||
|
||||
grid_sizer->Add( new wxCheckBox(this, ID_DISABLE_OK, "Disable \"OK\""), 0, wxALIGN_CENTRE_VERTICAL );
|
||||
grid_sizer->Add( new wxCheckBox(this, ID_DISABLE_CANCEL, "Disable \"Cancel\""), 0, wxALIGN_CENTRE_VERTICAL );
|
||||
|
||||
main_sizer->Add( grid_sizer, 0, wxALL, 10 );
|
||||
|
||||
wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
|
||||
@@ -1810,6 +1818,16 @@ TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
||||
SetSizerAndFit( main_sizer );
|
||||
}
|
||||
|
||||
void TestDefaultActionDialog::OnDisableOK(wxCommandEvent& event)
|
||||
{
|
||||
FindWindow(wxID_OK)->Enable(!event.IsChecked());
|
||||
}
|
||||
|
||||
void TestDefaultActionDialog::OnDisableCancel(wxCommandEvent& event)
|
||||
{
|
||||
FindWindow(wxID_CANCEL)->Enable(!event.IsChecked());
|
||||
}
|
||||
|
||||
void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
|
||||
{
|
||||
event.Skip( !m_catchListBoxDClick );
|
||||
@@ -1820,6 +1838,11 @@ void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent& WXUNUSED(even
|
||||
m_catchListBoxDClick = !m_catchListBoxDClick;
|
||||
}
|
||||
|
||||
void TestDefaultActionDialog::OnTextEnter(wxCommandEvent& event)
|
||||
{
|
||||
wxLogMessage("Text \"%s\" entered.", event.GetString());
|
||||
}
|
||||
|
||||
void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
TestDefaultActionDialog dialog( this );
|
||||
|
Reference in New Issue
Block a user