don't forward Enter presses to the default button if any of the ancestor windows has DLGC_WANTMESSAGE dialog code (slightly modified patch 1828309)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-11-10 01:15:03 +00:00
parent 283db4111b
commit 8e86978af5

View File

@@ -2219,13 +2219,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
case VK_RETURN: case VK_RETURN:
{ {
if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
{
// control wants to process Enter itself, don't
// call IsDialogMessage() which would consume it
return false;
}
#if wxUSE_BUTTON #if wxUSE_BUTTON
// currently active button should get enter press even // currently active button should get enter press even
// if there is a default button elsewhere so check if // if there is a default button elsewhere so check if
@@ -2247,9 +2240,32 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
} }
else // not a button itself, do we have default button? else // not a button itself, do we have default button?
{ {
wxTopLevelWindow * // check if this window or any of its ancestors
tlw = wxDynamicCast(wxGetTopLevelParent(this), // wants the message for itself (we always reserve
wxTopLevelWindow); // Ctrl-Enter for dialog navigation though)
wxWindow *win = this;
if ( !bCtrlDown )
{
while ( win && !win->IsTopLevel() )
{
if ( lDlgCode & DLGC_WANTMESSAGE )
{
// as it wants to process Enter itself,
// don't call IsDialogMessage() which
// would consume it
return false;
}
win = win->GetParent();
}
}
else // bCtrlDown
{
win = wxGetTopLevelParent(win);
}
wxTopLevelWindow * const
tlw = wxDynamicCast(win, wxTopLevelWindow);
if ( tlw ) if ( tlw )
{ {
btn = wxDynamicCast(tlw->GetDefaultItem(), btn = wxDynamicCast(tlw->GetDefaultItem(),