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_CATCH_LISTBOX_DCLICK 100
|
||||||
#define ID_LISTBOX 101
|
#define ID_LISTBOX 101
|
||||||
|
#define ID_DISABLE_OK 102
|
||||||
|
#define ID_DISABLE_CANCEL 103
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
|
BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
|
||||||
EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK, TestDefaultActionDialog::OnCatchListBoxDClick)
|
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_LISTBOX_DCLICK(ID_LISTBOX, TestDefaultActionDialog::OnListBoxDClick)
|
||||||
|
EVT_TEXT_ENTER(wxID_ANY, TestDefaultActionDialog::OnTextEnter)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
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 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 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 );
|
main_sizer->Add( grid_sizer, 0, wxALL, 10 );
|
||||||
|
|
||||||
wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
|
wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
|
||||||
@@ -1810,6 +1818,16 @@ TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
|||||||
SetSizerAndFit( main_sizer );
|
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)
|
void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
event.Skip( !m_catchListBoxDClick );
|
event.Skip( !m_catchListBoxDClick );
|
||||||
@@ -1820,6 +1838,11 @@ void TestDefaultActionDialog::OnCatchListBoxDClick(wxCommandEvent& WXUNUSED(even
|
|||||||
m_catchListBoxDClick = !m_catchListBoxDClick;
|
m_catchListBoxDClick = !m_catchListBoxDClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDefaultActionDialog::OnTextEnter(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage("Text \"%s\" entered.", event.GetString());
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
TestDefaultActionDialog dialog( this );
|
TestDefaultActionDialog dialog( this );
|
||||||
|
@@ -293,7 +293,10 @@ public:
|
|||||||
TestDefaultActionDialog( wxWindow *parent );
|
TestDefaultActionDialog( wxWindow *parent );
|
||||||
|
|
||||||
void OnListBoxDClick(wxCommandEvent& event);
|
void OnListBoxDClick(wxCommandEvent& event);
|
||||||
|
void OnDisableOK(wxCommandEvent& event);
|
||||||
|
void OnDisableCancel(wxCommandEvent& event);
|
||||||
void OnCatchListBoxDClick(wxCommandEvent& event);
|
void OnCatchListBoxDClick(wxCommandEvent& event);
|
||||||
|
void OnTextEnter(wxCommandEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_catchListBoxDClick;
|
bool m_catchListBoxDClick;
|
||||||
|
@@ -2403,8 +2403,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
// emulate the button click
|
// emulate the button click
|
||||||
btn = wxFindWinFromHandle(msg->hwnd);
|
btn = wxFindWinFromHandle(msg->hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
bProcess = false;
|
|
||||||
}
|
}
|
||||||
else // not a button itself, do we have default button?
|
else // not a button itself, do we have default button?
|
||||||
{
|
{
|
||||||
@@ -2464,6 +2462,13 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This "Return" key press won't be actually used for
|
||||||
|
// navigation so don't generate wxNavigationKeyEvent
|
||||||
|
// for it but still pass it to IsDialogMessage() as it
|
||||||
|
// may handle it in some other way (e.g. by playing the
|
||||||
|
// default error sound).
|
||||||
|
bProcess = false;
|
||||||
|
|
||||||
#endif // wxUSE_BUTTON
|
#endif // wxUSE_BUTTON
|
||||||
|
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
|
Reference in New Issue
Block a user