../
kernel
functions
add
all
apply_delta
assert
atan2
btn
btnp
camera
cd
char
chooser
circ
circfill
clip
cls
color
cos
count
cp
create_delta
create_gui
create_process
cursor
date
del
deli
env
error
exit
fetch
fetch_metadata
fget
fillp
foreach
fset
fstat
fullpath
get_clipboard
get_display
get_draw_target
get_spr
include
input
key
keyp
line
ls
map
max
memcpy
memmap
memset
menuitem
mget
mkdir
mouse
mouselock
mset
music
mv
note
on_event
open
oval
ovalfill
peek
peek2
peek4
peek8
peektext
pget
pid
pod
poke
poke2
poke4
poke8
printh
pset
pwd
readtext
rect
rectfill
rm
rrect
rrectfill
scoresub
send_message
set_clipboard
set_draw_target
set_spr
sfx
sin
socket
split
spr
sspr
stat
stop
store
store_metadata
sub
time
tokenoid
type
unmap
unpod
userdata
vec
vid
window
chooser(options, callback)
Overview
chooser opens a filenav process, allowing for the user to select one or more files and folders.
These act as if the files were dragged on top of the process when you select the files.
Files selected with chooser are able to be read and written from in sandboxed processes, no matter where they are sourced.
Arguments
options: string|table|nil
If options is a string, it is treated as {path=options}, acting as the starting path of the filenav.
When options is a table, it can have the following properties (all are optional):
- intention - the intent of the filenav (defaults to "choose_items")
- path - a path to a directory (defaults to "/")
- prompt - the bottom left text in the intention pane
- title - the title of the filenav process
- verb - the verb used in the bottom right in the intention pane
callback: function|nil
If callback is set, it is called when the user finishes their action, calling callback(msg).
If callback is nil, it defaults to a generic drop_items event.
Example
Sourced from the Picotron Manual
Print the selected items
on_event("drop_items", function(msg) print(pod(msg.items)) end)
chooser()
Choose a single file via a menu item by using the "select_file" intention:
window(240,80)
menuitem{
id = "select",
label = "Select File",
action = function()
chooser(
{
path = "/", -- starting path
intention = "select_file"
-- intention = "save_file_as" -- same but prompt for overwrites
},
function(msg) fn = msg.filename end
)
end
}
function _draw()
cls(7)
if (fn) print("selected: "..fn, 20,20, 1)
end