implement clipboard on iOS
This commit is contained in:
@@ -35,4 +35,6 @@
|
||||
- (void)share_file:(NSString*)file_path;
|
||||
- (void)tick;
|
||||
- (void)render_loop;
|
||||
- (std::string)clipboard_get_string;
|
||||
- (bool)clipboard_set_string:(const std::string&)s;
|
||||
@end
|
||||
|
||||
@@ -44,6 +44,18 @@ NSThread* lock_thread;
|
||||
std::recursive_mutex lock_mutex;
|
||||
|
||||
@implementation GameViewController
|
||||
- (std::string)clipboard_get_string
|
||||
{
|
||||
NSString* ns = [[UIPasteboard generalPasteboard] string];
|
||||
const char* ptr = [ns cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
return std::string(ptr);
|
||||
}
|
||||
- (bool)clipboard_set_string:(const std::string &)s
|
||||
{
|
||||
NSString* ns = [NSString stringWithUTF8String:s.c_str()];
|
||||
[[UIPasteboard generalPasteboard] setString:ns];
|
||||
return true;
|
||||
}
|
||||
- (void)crash
|
||||
{
|
||||
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
|
||||
Reference in New Issue
Block a user