Implement undo and redo for wxTextCtrl under Mac
Use the parent undo manager to implement these functions.
This commit is contained in:
@@ -136,12 +136,18 @@ public:
|
|||||||
|
|
||||||
virtual void controlTextDidChange() wxOVERRIDE;
|
virtual void controlTextDidChange() wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual bool CanUndo() const wxOVERRIDE;
|
||||||
|
virtual void Undo() wxOVERRIDE;
|
||||||
|
virtual bool CanRedo() const wxOVERRIDE;
|
||||||
|
virtual void Redo() wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DoUpdateTextStyle();
|
void DoUpdateTextStyle();
|
||||||
|
|
||||||
NSScrollView* m_scrollView;
|
NSScrollView* m_scrollView;
|
||||||
NSTextView* m_textView;
|
NSTextView* m_textView;
|
||||||
bool m_useCharWrapping;
|
bool m_useCharWrapping;
|
||||||
|
NSUndoManager* m_undoManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
|
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
|
||||||
|
@@ -773,6 +773,12 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long s
|
|||||||
|
|
||||||
[tv setDelegate: tv];
|
[tv setDelegate: tv];
|
||||||
|
|
||||||
|
m_undoManager = nil;
|
||||||
|
if ( wxPeer && wxPeer->GetParent() && wxPeer->GetParent()->GetPeer() && wxPeer->GetParent()->GetPeer()->GetWXWidget() )
|
||||||
|
m_undoManager = [wxPeer->GetParent()->GetPeer()->GetWXWidget() undoManager];
|
||||||
|
|
||||||
|
[tv setAllowsUndo:YES];
|
||||||
|
|
||||||
InstallEventHandler(tv);
|
InstallEventHandler(tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,6 +1025,38 @@ void wxNSTextViewControl::controlTextDidChange()
|
|||||||
DoUpdateTextStyle();
|
DoUpdateTextStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxNSTextViewControl::CanUndo() const
|
||||||
|
{
|
||||||
|
if ( !m_undoManager )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return [m_undoManager canUndo];
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNSTextViewControl::Undo()
|
||||||
|
{
|
||||||
|
if ( !m_undoManager )
|
||||||
|
return;
|
||||||
|
|
||||||
|
[m_undoManager undo];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNSTextViewControl::CanRedo() const
|
||||||
|
{
|
||||||
|
if ( !m_undoManager )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return [m_undoManager canRedo];
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNSTextViewControl::Redo()
|
||||||
|
{
|
||||||
|
if ( !m_undoManager )
|
||||||
|
return;
|
||||||
|
|
||||||
|
[m_undoManager redo];
|
||||||
|
}
|
||||||
|
|
||||||
void wxNSTextViewControl::DoUpdateTextStyle()
|
void wxNSTextViewControl::DoUpdateTextStyle()
|
||||||
{
|
{
|
||||||
if ( m_useCharWrapping )
|
if ( m_useCharWrapping )
|
||||||
|
Reference in New Issue
Block a user