Open platform File Explorer

I’ve recently discovered the RichText component, which is fantastic (I’ve been using Label and BMFont everywhere) when I want more flexibility, and I just now realized I can actually open URLs with it (very cool!).

What I’d love to be able to do is open the platform’s File Explorer (Windows File Explorer, Mac Finder, and if possible, access to iOS Files). I’ve tried creating a url with “file://” but that doesn’t work. Any suggestions?

Thanks!

You can create platform specific functions if cocos does not have default behavior for what you want to do. For example the RichText callback can invoke a callback to a function. The function can do some form of:

#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
        <do the native file opener (NSOpenPanel or whatever it is) in Objective-C++ file>

#elif
...
<for separate platforms opening different stuff, might require JNI, ObjC calls etc>

#endif
1 Like