Fixed clipboard tests on iOS
This commit is contained in:
@@ -33,7 +33,14 @@ bool UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text)
|
|||||||
return SDL_SetError("The clipboard is not available on tvOS");
|
return SDL_SetError("The clipboard is not available on tvOS");
|
||||||
#else
|
#else
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->internal;
|
||||||
|
data.setting_clipboard = true;
|
||||||
|
if (text && *text) {
|
||||||
[UIPasteboard generalPasteboard].string = @(text);
|
[UIPasteboard generalPasteboard].string = @(text);
|
||||||
|
} else {
|
||||||
|
[UIPasteboard generalPasteboard].items = nil;
|
||||||
|
}
|
||||||
|
data.setting_clipboard = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -61,7 +68,7 @@ bool UIKit_HasClipboardText(SDL_VideoDevice *_this)
|
|||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
#ifndef SDL_PLATFORM_TVOS
|
#ifndef SDL_PLATFORM_TVOS
|
||||||
if ([UIPasteboard generalPasteboard].string != nil) {
|
if ([UIPasteboard generalPasteboard].hasStrings) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -80,11 +87,14 @@ void UIKit_InitClipboard(SDL_VideoDevice *_this)
|
|||||||
object:nil
|
object:nil
|
||||||
queue:nil
|
queue:nil
|
||||||
usingBlock:^(NSNotification *note) {
|
usingBlock:^(NSNotification *note) {
|
||||||
|
if (!data.setting_clipboard) {
|
||||||
// TODO: compute mime types
|
// TODO: compute mime types
|
||||||
SDL_SendClipboardUpdate(false, NULL, 0);
|
SDL_SendClipboardUpdate(false, NULL, 0);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
data.pasteboardObserver = observer;
|
data.pasteboardObserver = observer;
|
||||||
|
data.setting_clipboard = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
@property(nonatomic, assign) id pasteboardObserver;
|
@property(nonatomic, assign) id pasteboardObserver;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) bool setting_clipboard;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#ifdef SDL_PLATFORM_VISIONOS
|
#ifdef SDL_PLATFORM_VISIONOS
|
||||||
|
|||||||
Reference in New Issue
Block a user