Use a private undo manager for wxTextCtrl

This allows each control have its own undo history, independent of the
other ones, as expected by the wx API, rather than using an undo manager
shared by all controls in the same TLW.
This commit is contained in:
Stefan Csomor
2021-08-19 19:56:03 +02:00
committed by Vadim Zeitlin
parent 6c292d264c
commit 4fcd18e6ea
2 changed files with 18 additions and 3 deletions

View File

@@ -436,6 +436,8 @@ public:
- (void)textDidChange:(NSNotification *)aNotification;
- (void)changeColor:(id)sender;
@property (retain) NSUndoManager* undoManager;
@end
@interface wxNSComboBox : NSComboBox

View File

@@ -426,6 +426,16 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
}
}
- (instancetype)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
if ( self )
{
self.undoManager = [[[NSUndoManager alloc] init] autorelease];
}
return self;
}
- (void)textDidChange:(NSNotification *)aNotification
{
wxUnusedVar(aNotification);
@@ -434,6 +444,11 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
impl->controlTextDidChange();
}
- (nullable NSUndoManager *)undoManagerForTextView:(NSTextView *)view
{
return self.undoManager;
}
- (void)changeColor:(id)sender
{
@@ -773,9 +788,7 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long s
[tv setDelegate: tv];
m_undoManager = nil;
if ( wxPeer && wxPeer->GetParent() && wxPeer->GetParent()->GetPeer() && wxPeer->GetParent()->GetPeer()->GetWXWidget() )
m_undoManager = [wxPeer->GetParent()->GetPeer()->GetWXWidget() undoManager];
m_undoManager = tv.undoManager;
[tv setAllowsUndo:YES];