diff --git a/docs/changes.txt b/docs/changes.txt index cc8d7a83f7..eb769ce072 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -147,6 +147,7 @@ All (GUI): - Fix wxGCDC::SetDeviceClippingRegion(). - Never restore size smaller than the best one in wxPersistentTLW. - Fix escaping/unescaping characters in wxLongStringProperty in wxPG (mikek). +- Ensure that navigation order reflects layout of wxStdDialogButtonSizer. wxGTK: diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 9ed3bd1c43..92cd35b9f9 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -2764,15 +2764,25 @@ void wxStdDialogButtonSizer::SetCancelButton( wxButton *button ) void wxStdDialogButtonSizer::Realize() { + wxButton* lastAdded = NULL; #ifdef __WXMAC__ Add(0, 0, 0, wxLEFT, 6); if (m_buttonHelp) + { Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 6); + lastAdded = m_buttonHelp; + } if (m_buttonNegative){ // HIG POLICE BULLETIN - destructive buttons need extra padding // 24 pixels on either side Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 12); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonNegative->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonNegative; } // extra whitespace between help/negative and cancel/ok buttons @@ -2782,12 +2792,27 @@ void wxStdDialogButtonSizer::Realize() Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 6); // Cancel or help should be default // m_buttonCancel->SetDefaultButton(); + + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonCancel->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonCancel; } // Ugh, Mac doesn't really have apply dialogs, so I'll just // figure the best place is between Cancel and OK if (m_buttonApply) + { Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 6); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonApply->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonApply; + } if (m_buttonAffirmative){ Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT, 6); @@ -2798,6 +2823,11 @@ void wxStdDialogButtonSizer::Realize() if (m_buttonNegative) m_buttonNegative->SetLabel(_("Don't Save")); } + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonAffirmative->MoveAfterInTabOrder(lastAdded); + } } // Extra space around and at the right @@ -2816,22 +2846,56 @@ void wxStdDialogButtonSizer::Realize() AddSpacer(9); if (m_buttonHelp) + { Add(m_buttonHelp, flagsBtn); + lastAdded = m_buttonHelp; + } // Align the rest of the buttons to the right. AddStretchSpacer(); if (m_buttonNegative) + { Add(m_buttonNegative, flagsBtn); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonNegative->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonNegative; + } if (m_buttonApply) + { Add(m_buttonApply, flagsBtn); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonApply->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonApply; + } if (m_buttonCancel) + { Add(m_buttonCancel, flagsBtn); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonCancel->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonCancel; + } if (m_buttonAffirmative) + { Add(m_buttonAffirmative, flagsBtn); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonAffirmative->MoveAfterInTabOrder(lastAdded); + } + } // Ensure that the right margin is 12 as well. AddSpacer(9); @@ -2843,45 +2907,102 @@ void wxStdDialogButtonSizer::Realize() if (m_buttonAffirmative){ Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonAffirmative->ConvertDialogToPixels(wxSize(2, 0)).x); + lastAdded = m_buttonAffirmative; } if (m_buttonNegative){ Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonNegative->ConvertDialogToPixels(wxSize(2, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonNegative->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonNegative; } if (m_buttonCancel){ Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonCancel->ConvertDialogToPixels(wxSize(2, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonCancel->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonCancel; } + if (m_buttonApply) + { Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonApply->ConvertDialogToPixels(wxSize(2, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonApply->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonApply; + } if (m_buttonHelp) + { Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(2, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonHelp->MoveAfterInTabOrder(lastAdded); + } + } #else // GTK+1 and any other platform // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog if (m_buttonHelp) + { Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(4, 0)).x); + lastAdded = m_buttonHelp; + } // extra whitespace between help and cancel/ok buttons Add(0, 0, 1, wxEXPAND, 0); if (m_buttonApply) + { Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonApply->ConvertDialogToPixels(wxSize(4, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonApply->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonApply; + } if (m_buttonAffirmative){ Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonAffirmative->ConvertDialogToPixels(wxSize(4, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonAffirmative->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonAffirmative; } if (m_buttonNegative){ Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonNegative->ConvertDialogToPixels(wxSize(4, 0)).x); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonNegative->MoveAfterInTabOrder(lastAdded); + } + lastAdded = m_buttonNegative; } if (m_buttonCancel){ Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonCancel->ConvertDialogToPixels(wxSize(4, 0)).x); // Cancel or help should be default // m_buttonCancel->SetDefaultButton(); + // Button should follow previous one in the keyboard navigation order. + if ( lastAdded ) + { + m_buttonCancel->MoveAfterInTabOrder(lastAdded); + } } #endif