diff --git a/docs/changes.txt b/docs/changes.txt index ab7e9edf94..60838d0c60 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -157,6 +157,8 @@ wxOSX: - Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner). - Don't try to open command line arguments as files (Jeff Hostetler). - Implement wxDataViewCtrl::SetRowHeight(). +- Add OSXEnableAutomaticQuoteSubstitution(), OSXEnableAutomaticDashSubstitution() + and OSXDisableAllSmartSubstitutions() to control wxTextCtrl smart behavior. Unix: diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index 24b4f8cff5..de74297139 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -95,6 +95,9 @@ public: virtual bool HasOwnContextMenu() const { return true; } virtual void CheckSpelling(bool check); + virtual void EnableAutomaticQuoteSubstitution(bool enable); + virtual void EnableAutomaticDashSubstitution(bool enable); + virtual wxSize GetBestSize() const; protected: diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index b21995257a..ddc5701bc2 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -688,6 +688,8 @@ public : virtual int GetLineLength(long lineNo) const ; virtual wxString GetLineText(long lineNo) const ; virtual void CheckSpelling(bool WXUNUSED(check)) { } + virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {} + virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {} virtual wxSize GetBestSize() const { return wxDefaultSize; } diff --git a/include/wx/osx/textctrl.h b/include/wx/osx/textctrl.h index 31892a77c6..48577f7ba0 100644 --- a/include/wx/osx/textctrl.h +++ b/include/wx/osx/textctrl.h @@ -130,6 +130,10 @@ public: virtual void MacSuperChangedPosition() wxOVERRIDE; virtual void MacCheckSpelling(bool check); + void OSXEnableAutomaticQuoteSubstitution(bool enable); + void OSXEnableAutomaticDashSubstitution(bool enable); + void OSXDisableAllSmartSubstitutions(); + protected: // common part of all ctors void Init(); diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index bde2b3c07c..9bc082dc96 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -863,6 +863,18 @@ void wxNSTextViewControl::CheckSpelling(bool check) [m_textView setContinuousSpellCheckingEnabled: check]; } +void wxNSTextViewControl::EnableAutomaticQuoteSubstitution(bool enable) +{ + if (m_textView) + [m_textView setAutomaticQuoteSubstitutionEnabled:enable]; +} + +void wxNSTextViewControl::EnableAutomaticDashSubstitution(bool enable) +{ + if (m_textView) + [m_textView setAutomaticDashSubstitutionEnabled:enable]; +} + wxSize wxNSTextViewControl::GetBestSize() const { if (m_textView && [m_textView layoutManager]) diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 9241897c18..d9fa0f4c4c 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -139,6 +139,22 @@ void wxTextCtrl::MacCheckSpelling(bool check) GetTextPeer()->CheckSpelling(check); } +void wxTextCtrl::OSXEnableAutomaticQuoteSubstitution(bool enable) +{ + GetTextPeer()->EnableAutomaticQuoteSubstitution(enable); +} + +void wxTextCtrl::OSXEnableAutomaticDashSubstitution(bool enable) +{ + GetTextPeer()->EnableAutomaticDashSubstitution(enable); +} + +void wxTextCtrl::OSXDisableAllSmartSubstitutions() +{ + OSXEnableAutomaticDashSubstitution(false); + OSXEnableAutomaticQuoteSubstitution(false); +} + bool wxTextCtrl::SetFont( const wxFont& font ) { if ( !wxTextCtrlBase::SetFont( font ) )