MCPcopy Create free account
hub / github.com/cinder/Cinder / setString

Method setString

src/cinder/Clipboard.cpp:200–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void Clipboard::setString( const std::string &str )
201{
202#if defined( CINDER_MAC )
203 [[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner:nil];
204 [[NSPasteboard generalPasteboard] setString:[NSString stringWithUTF8String:str.c_str()] forType: NSStringPboardType];
205#elif defined( CINDER_COCOA_TOUCH )
206 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
207 pasteboard.string = [NSString stringWithUTF8String:str.c_str()];
208#elif defined( CINDER_MSW )
209 if( ! ::OpenClipboard( NULL ) ) {
210 CI_LOG_E( "Failed to open clipboard" );
211 return;
212 }
213 ::EmptyClipboard();
214 std::u16string wstr = toUtf16( str );
215 HANDLE hglbCopy = ::GlobalAlloc( GMEM_MOVEABLE, sizeof(uint16_t) * (wstr.length()+1) );
216 // Lock the handle and copy the text to the buffer.
217 void *lptstrCopy = ::GlobalLock( hglbCopy );
218 memcpy( lptstrCopy, &wstr[0], sizeof(uint16_t) * (wstr.length()+1) );
219 ::GlobalUnlock( hglbCopy );
220 ::SetClipboardData( CF_UNICODETEXT, hglbCopy );
221 ::CloseClipboard();
222#elif defined( CINDER_LINUX )
223 glfwSetClipboardString( (GLFWwindow*)app::getWindow()->getNative(), str.c_str() );
224#endif
225}
226
227void Clipboard::setImage( ImageSourceRef imageSource, ImageTarget::Options options )
228{

Callers

nothing calls this directly

Calls 6

toUtf16Function · 0.85
glfwSetClipboardStringFunction · 0.85
getWindowFunction · 0.50
c_strMethod · 0.45
lengthMethod · 0.45
getNativeMethod · 0.45

Tested by

no test coverage detected