Add API to control OS X wxTextCtrl’s smart behavior

Allow the user to customize smart quotes and dashes substutions on OS X
and also provide the OSXDisableAllSmartSubstitutions() method for
disabling them all at once.
This commit is contained in:
Václav Slavík
2016-10-10 12:17:40 +02:00
parent 3028fd40a0
commit 90e1769569
6 changed files with 39 additions and 0 deletions

View File

@@ -157,6 +157,8 @@ wxOSX:
- Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner). - Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner).
- Don't try to open command line arguments as files (Jeff Hostetler). - Don't try to open command line arguments as files (Jeff Hostetler).
- Implement wxDataViewCtrl::SetRowHeight(). - Implement wxDataViewCtrl::SetRowHeight().
- Add OSXEnableAutomaticQuoteSubstitution(), OSXEnableAutomaticDashSubstitution()
and OSXDisableAllSmartSubstitutions() to control wxTextCtrl smart behavior.
Unix: Unix:

View File

@@ -95,6 +95,9 @@ public:
virtual bool HasOwnContextMenu() const { return true; } virtual bool HasOwnContextMenu() const { return true; }
virtual void CheckSpelling(bool check); virtual void CheckSpelling(bool check);
virtual void EnableAutomaticQuoteSubstitution(bool enable);
virtual void EnableAutomaticDashSubstitution(bool enable);
virtual wxSize GetBestSize() const; virtual wxSize GetBestSize() const;
protected: protected:

View File

@@ -688,6 +688,8 @@ public :
virtual int GetLineLength(long lineNo) const ; virtual int GetLineLength(long lineNo) const ;
virtual wxString GetLineText(long lineNo) const ; virtual wxString GetLineText(long lineNo) const ;
virtual void CheckSpelling(bool WXUNUSED(check)) { } virtual void CheckSpelling(bool WXUNUSED(check)) { }
virtual void EnableAutomaticQuoteSubstitution(bool WXUNUSED(enable)) {}
virtual void EnableAutomaticDashSubstitution(bool WXUNUSED(enable)) {}
virtual wxSize GetBestSize() const { return wxDefaultSize; } virtual wxSize GetBestSize() const { return wxDefaultSize; }

View File

@@ -130,6 +130,10 @@ public:
virtual void MacSuperChangedPosition() wxOVERRIDE; virtual void MacSuperChangedPosition() wxOVERRIDE;
virtual void MacCheckSpelling(bool check); virtual void MacCheckSpelling(bool check);
void OSXEnableAutomaticQuoteSubstitution(bool enable);
void OSXEnableAutomaticDashSubstitution(bool enable);
void OSXDisableAllSmartSubstitutions();
protected: protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -863,6 +863,18 @@ void wxNSTextViewControl::CheckSpelling(bool check)
[m_textView setContinuousSpellCheckingEnabled: 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 wxSize wxNSTextViewControl::GetBestSize() const
{ {
if (m_textView && [m_textView layoutManager]) if (m_textView && [m_textView layoutManager])

View File

@@ -139,6 +139,22 @@ void wxTextCtrl::MacCheckSpelling(bool check)
GetTextPeer()->CheckSpelling(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 ) bool wxTextCtrl::SetFont( const wxFont& font )
{ {
if ( !wxTextCtrlBase::SetFont( font ) ) if ( !wxTextCtrlBase::SetFont( font ) )