switching to pasteboard
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46163 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -448,9 +448,12 @@ static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handl
|
|||||||
textCtrl->GetSelection( &from , &to ) ;
|
textCtrl->GetSelection( &from , &to ) ;
|
||||||
wxString val = textCtrl->GetValue() ;
|
wxString val = textCtrl->GetValue() ;
|
||||||
val = val.Mid( from , to - from ) ;
|
val = val.Mid( from , to - from ) ;
|
||||||
ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ;
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
||||||
verify_noerr( ClearScrap( &scrapRef ) ) ;
|
verify_noerr( PasteboardClear( pasteboard ) ) ;
|
||||||
verify_noerr( PutScrapFlavor( scrapRef , kTXNTextData , 0 , val.length() , val.c_str() ) ) ;
|
PasteboardSynchronize( pasteboard );
|
||||||
|
CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)val.c_str(), val.length() );
|
||||||
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) 1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
|
||||||
|
CFRelease( data );
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
@@ -458,23 +461,35 @@ static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handl
|
|||||||
case kEventServicePaste :
|
case kEventServicePaste :
|
||||||
if ( textCtrl )
|
if ( textCtrl )
|
||||||
{
|
{
|
||||||
ScrapRef scrapRef = cEvent.GetParameter< ScrapRef > ( kEventParamScrapRef , typeScrapRef ) ;
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
||||||
Size textSize, pastedSize ;
|
PasteboardSynchronize( pasteboard );
|
||||||
verify_noerr( GetScrapFlavorSize(scrapRef, kTXNTextData, &textSize) ) ;
|
ItemCount itemCount;
|
||||||
textSize++ ;
|
verify_noerr( PasteboardGetItemCount( pasteboard, &itemCount ) );
|
||||||
char *content = new char[textSize] ;
|
for( UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex++ )
|
||||||
GetScrapFlavorData(scrapRef, kTXNTextData, &pastedSize, content );
|
{
|
||||||
content[textSize - 1] = 0 ;
|
PasteboardItemID itemID;
|
||||||
|
if ( PasteboardGetItemIdentifier( pasteboard, itemIndex, &itemID ) == noErr )
|
||||||
|
{
|
||||||
|
CFDataRef flavorData = NULL;
|
||||||
|
if ( PasteboardCopyItemFlavorData( pasteboard, itemID, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData ) == noErr )
|
||||||
|
{
|
||||||
|
CFIndex flavorDataSize = CFDataGetLength( flavorData );
|
||||||
|
char *content = new char[flavorDataSize+1] ;
|
||||||
|
memcpy( content, CFDataGetBytePtr( flavorData ), flavorDataSize );
|
||||||
|
content[flavorDataSize]=0;
|
||||||
|
CFRelease( flavorData );
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
textCtrl->WriteText( wxString( content , wxConvLocal ) );
|
textCtrl->WriteText( wxString( content , wxConvLocal ) );
|
||||||
#else
|
#else
|
||||||
textCtrl->WriteText( wxString( content ) ) ;
|
textCtrl->WriteText( wxString( content ) ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] content ;
|
delete[] content ;
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user