AshampooSystems / boden

Purely native C++ cross-platform GUI framework for Android and iOS development. https://www.boden.io
Other
1.68k stars 96 forks source link

Implement Application::copyToClipboard for iOS #16

Closed mrexodia closed 5 years ago

mrexodia commented 5 years ago

Usage:

App()->copyToClipboard("Hello clipboard");

Currently I do not have enough disk space to test on an emulator on Android unfortunately. I will try to make space and implement it for Android and OSX too. I'll sign the CLA in a separate PR once that's applicable.

gitoby commented 5 years ago

See my comments on #14

mrexodia commented 5 years ago

I implemented the interface for every platform, but I have no idea how to get the information from Java to copy to the clipboard. Some direction would be appreciated!

Maddimax commented 5 years ago

I found this SO answer: https://stackoverflow.com/questions/19253786/how-to-copy-text-to-clip-board-in-android

The easiest way would be to add a function to NativeRootActivity.java ( probably a public static function ), then make that function available to C++ via android/NativeRootActivity.h and call it from android/UIApplication.cpp

mrexodia commented 5 years ago

Yeah that’s what I did, but you need getSystemService which is a member function so it cannot be called from my static method...

Maddimax commented 5 years ago

You can use NativeRootActivity.getRootActivity() to access the main activity object. NativeRootActivity.getRootActivitiy().getSystemService(...) should get you there.

mrexodia commented 5 years ago

Thanks, I will look into it @Maddimax!

mrexodia commented 5 years ago

Alright, I implemented and tested Application::copyToClipboard for all platforms and rebased on the latest master. Locally I have modifications to bodendemo with a button to test the function, should I add that too?

Is there a way to have AndroidStudio show the cpp/java files like Xcode? It was lagging horribly and I couldn't get it to work, so I just ran ./boden build instead for testing Android.

gitoby commented 5 years ago

Yes, a test button in the demo app would be nice!

You should be able to see the cpp/java files in Android Studio. If you can't find them, double press Shift and it should bring up a quick open dialog (similar to Ctrl/Cmd+P in Sublime). If you enter the filename there, it should show up.

Regarding the Android Studio and lagging: Yes, that's an issue. It's usually caused by Gradle sync and it's worse when the project is first opened. We found that it gets better if you generate a single target only (using boden open -t bodendemo). It should get faster once the initial indexing/sync is completed. Unfortunately there doesn't seem to be much else we can do about it right now.

mrexodia commented 5 years ago

Alright, I re-added the page, hopefully everything is done now :)

Maddimax commented 5 years ago

Thanks a lot for the time and effort you put into this!