MobileFilePicker
| Kind | class |
| Package | mobile.files |
| Full name | mobile.files.MobileFilePicker |
| Source | source/mobile/files/MobileFilePicker.hx |
Cross-platform file picker facade.
On Android it drives the native Storage Access Framework document picker
(ACTION_OPEN_DOCUMENT / ACTION_CREATE_DOCUMENT /
ACTION_OPEN_DOCUMENT_TREE); on desktop it uses Lime's native file
dialogs. Results come back through callbacks with null meaning the user
canceled (or the operation is unsupported on this target).
This is what editors (charting, character, ...) should use instead of
calling lime.ui.FileDialog directly, so imports/exports work on mobile.
Public methods
openFile
static function openFile(onResult:PickedFile->Void, ?extensions:Array<String>, ?title:String):Bool
Opens a file picker and reads the picked file into memory.
@param onResult called with the picked file, or null when canceled @param extensions optional extension filter, e.g. ["json"] @param title optional picker title @return false when picking is not supported on this target
| Parameter | Type | Default |
|---|---|---|
onResult | PickedFile->Void, ?extensions:Array<String>, ?title:String | — |
saveFile
static function saveFile(data:Bytes, suggestedName:String, ?mime:String, ?title:String, onDone:String->Void = null):Bool
Opens a "save as" picker and writes the data to the picked location.
@param onDone called with the resulting path (desktop) or content URI (Android), or null when canceled/unsupported @return false when saving is not supported on this target
| Parameter | Type | Default |
|---|---|---|
data | Bytes | — |
suggestedName | String | — |
mime (optional) | String | — |
title (optional) | String | — |
onDone | String->Void = null | — |
saveText
static function saveText(text:String, suggestedName:String, ?mime:String, ?title:String, onDone:String->Void = null):Bool
Convenience wrapper for saving text content.
| Parameter | Type | Default |
|---|---|---|
text | String | — |
suggestedName | String | — |
mime (optional) | String | — |
title (optional) | String | — |
onDone | String->Void = null | — |
openFolder
static function openFolder(onResult:String->Void, ?title:String):Bool
Opens a directory picker. @param onResult called with the picked directory path (desktop) or tree URI (Android), or null when canceled
| Parameter | Type | Default |
|---|---|---|
onResult | String->Void, ?title:String | — |
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
activeDialog | Dynamic | yes |
| Method |
|---|
static function guessMime(fileName:String):String |