diff --git a/docs/changes.txt b/docs/changes.txt index 7128686cf0..d79c1041c9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -343,6 +343,9 @@ Deprecated methods and their replacements - wxFont::SetNoAntiAliasing() was deprecated, it never really worked in most ports and was always marked as "experimental" API. It will be replaced with wxDC-level anti-aliasing control in the future. +- wxValidator::SetBellOnError() incorrectly interpreted its argument (it + disabled the bell when it was true) and was replaced by SuppressBellOnError() + with more expected semantics. Major new features in this release diff --git a/include/wx/validate.h b/include/wx/validate.h index 3cd0fdc435..f6832d16d1 100644 --- a/include/wx/validate.h +++ b/include/wx/validate.h @@ -62,10 +62,23 @@ public: wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; } void SetWindow(wxWindowBase *win) { m_validatorWindow = win; } - // validators beep by default if invalid key is pressed, these functions - // allow to change it + // validators beep by default if invalid key is pressed, this function + // allows to change this + static void SuppressBellOnError(bool suppress = true) + { ms_isSilent = suppress; } + + // test if beep is currently disabled static bool IsSilent() { return ms_isSilent; } - static void SetBellOnError(bool doIt = true) { ms_isSilent = doIt; } + + // this function is deprecated because it handled its parameter + // unnaturally: it disabled the bell when it was true, not false as could + // be expected; use SuppressBellOnError() instead +#if WXWIN_COMPATIBILITY_2_8 + wxDEPRECATED_INLINE( + static void SetBellOnError(bool doIt = true), + ms_isSilent = doIt; + ) +#endif protected: wxWindowBase *m_validatorWindow; diff --git a/interface/wx/validate.h b/interface/wx/validate.h index bb2077bcaa..0121382602 100644 --- a/interface/wx/validate.h +++ b/interface/wx/validate.h @@ -74,8 +74,14 @@ public: /** This functions switches on or turns off the error sound produced by the validators if an invalid key is pressed. + + @since 2.9.1 + + @param suppress + If @true, error sound is not played when a validator detects an + error. If @false, error sound is enabled. */ - static void SetBellOnError(bool doIt = true); + static void SuppressBellOnError(bool suppress = true); /** Associates a window with the validator. diff --git a/samples/validate/validate.cpp b/samples/validate/validate.cpp index 4840a7d6a3..dc03e879b7 100644 --- a/samples/validate/validate.cpp +++ b/samples/validate/validate.cpp @@ -173,7 +173,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int // All validators share a common (static) flag that controls // whether they beep on error. Here we turn it off: - wxValidator::SetBellOnError(m_silent); + wxValidator::SuppressBellOnError(m_silent); file_menu->Check(VALIDATE_TOGGLE_BELL, !wxValidator::IsSilent()); #if wxUSE_STATUSBAR @@ -221,7 +221,7 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleBell(wxCommandEvent& event) { m_silent = !m_silent; - wxValidator::SetBellOnError(m_silent); + wxValidator::SuppressBellOnError(m_silent); event.Skip(); }