Replace wxValidator::SetBellOnError() with SuppressBellOnError().
SetBellOnError() erroneously inversed the value of its parameter. Fixing it to behave correctly could silently break the existing code which might work around this bug already because it always behaved like this (ever since it was added 10.5 years ago). So instead simply deprecate this function and add a new SuppressBellOnError() one which behaves as expected. Closes #11318. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -343,6 +343,9 @@ Deprecated methods and their replacements
|
|||||||
- wxFont::SetNoAntiAliasing() was deprecated, it never really worked in most
|
- wxFont::SetNoAntiAliasing() was deprecated, it never really worked in most
|
||||||
ports and was always marked as "experimental" API. It will be replaced with
|
ports and was always marked as "experimental" API. It will be replaced with
|
||||||
wxDC-level anti-aliasing control in the future.
|
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
|
Major new features in this release
|
||||||
|
@@ -62,10 +62,23 @@ public:
|
|||||||
wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; }
|
wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; }
|
||||||
void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
|
void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
|
||||||
|
|
||||||
// validators beep by default if invalid key is pressed, these functions
|
// validators beep by default if invalid key is pressed, this function
|
||||||
// allow to change it
|
// 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 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:
|
protected:
|
||||||
wxWindowBase *m_validatorWindow;
|
wxWindowBase *m_validatorWindow;
|
||||||
|
@@ -74,8 +74,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
This functions switches on or turns off the error sound produced by the
|
This functions switches on or turns off the error sound produced by the
|
||||||
validators if an invalid key is pressed.
|
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.
|
Associates a window with the validator.
|
||||||
|
@@ -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
|
// All validators share a common (static) flag that controls
|
||||||
// whether they beep on error. Here we turn it off:
|
// 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());
|
file_menu->Check(VALIDATE_TOGGLE_BELL, !wxValidator::IsSilent());
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
@@ -221,7 +221,7 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event))
|
|||||||
void MyFrame::OnToggleBell(wxCommandEvent& event)
|
void MyFrame::OnToggleBell(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
m_silent = !m_silent;
|
m_silent = !m_silent;
|
||||||
wxValidator::SetBellOnError(m_silent);
|
wxValidator::SuppressBellOnError(m_silent);
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user