Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS.set_clipboard() doesn't work on iOS #52228

Closed
kyoz opened this issue Aug 29, 2021 · 5 comments
Closed

OS.set_clipboard() doesn't work on iOS #52228

kyoz opened this issue Aug 29, 2021 · 5 comments

Comments

@kyoz
Copy link

kyoz commented Aug 29, 2021

Godot version

3.3.2-stable

System information

Macbook Pro 15" Mid 2015 - BigSur 11.5.2

Issue description

Maybe i'm missing something but this doesn't work on iOS, both on Simulator (14.0.1) and Real Device (Iphone 5s - 12.0.1)

OS.set_clipboard("Hello")

or

OS.clipboard = "Hello"

They work well on Android but doesn't know why it doesn't work on iOS. There is no error when calling too so i don't know exactly it's an error or missing something.

Steps to reproduce

Just calling these on an iOS simulators or real devices.

OS.set_clipboard("Hello")

or

OS.clipboard = "Hello"

Minimal reproduction project

iOS-Clipboard-issue.zip

@Calinou
Copy link
Member

Calinou commented Aug 29, 2021

Does iOS even support setting clipboard data outside of its virtual keyboard? Maybe @bruvzg knows about this.

@kyoz
Copy link
Author

kyoz commented Aug 30, 2021

Hi @Calinou , iOS does have UIPasteBoard

By global search on main branch i can see UIPasteBoard implement for ios

But in 3.3.2-stable i can't find any thing relate to UIPasteBoard

So i manually add these and it work :D. Doesn't know if it correctly or i'm missing something but for now it work for me.

platform/iphone/os_iphone.h

  virtual void set_clipboard(const String &p_text) ;
  virtual String get_clipboard() const;

platform/iphone/os_iphone.mm

void OSIPhone::set_clipboard(const String &p_text) {
	[UIPasteboard generalPasteboard].string = [NSString stringWithUTF8String:p_text.utf8()];
}

String OSIPhone::get_clipboard() const {
	NSString *text = [UIPasteboard generalPasteboard].string;

	return String::utf8([text UTF8String]);
}

@Calinou
Copy link
Member

Calinou commented Aug 30, 2021

So i manually add these and it work :D. Doesn't know if it correctly or i'm missing something but for now it work for me.

Feel free to open a pull request for this against the 3.x branch 🙂

@kyoz
Copy link
Author

kyoz commented Aug 30, 2021

Ok @Calinou

@akien-mga
Copy link
Member

Fixed by #52540.

@akien-mga akien-mga added this to the 3.4 milestone Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants