Implement wxClipboardTextEvent support in wxOSX

Emit wxEVT_TEXT_{COPY,CUT,PASTE} from NSTextView methods, calling native
implementation if not handled. NSTextField-based wxTextCtrl is not
supported, because it doesn't have the copy:/cut:/paste: methods.
This commit is contained in:
Václav Slavík
2017-01-11 16:46:32 +01:00
parent 1a1a2ffdf8
commit eecf084d4d

View File

@@ -448,6 +448,37 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
return NO;
}
- (BOOL)_handleClipboardEvent:(wxEventType)type
{
wxWidgetImpl *impl = wxWidgetImpl::FindFromWXWidget(self);
wxWindow* wxpeer = impl ? impl->GetWXPeer() : NULL;
if ( wxpeer )
{
wxClipboardTextEvent evt(type, wxpeer->GetId());
evt.SetEventObject(wxpeer);
return wxpeer->HandleWindowEvent(evt);
}
return false;
}
- (void)copy:(id)sender
{
if ( ![self _handleClipboardEvent:wxEVT_TEXT_COPY] )
[super copy:sender];
}
- (void)cut:(id)sender
{
if ( ![self _handleClipboardEvent:wxEVT_TEXT_CUT] )
[super cut:sender];
}
- (void)paste:(id)sender
{
if ( ![self _handleClipboardEvent:wxEVT_TEXT_PASTE] )
[super paste:sender];
}
@end
@implementation wxNSTextField