Added support for dropping a folder onto the window

This commit is contained in:
rxi 2020-05-23 11:31:08 +01:00
parent e45b3e2bc0
commit 28b1844a8b
1 changed files with 10 additions and 5 deletions

View File

@ -318,12 +318,17 @@ function core.on_event(type, ...)
core.root_view:on_mouse_wheel(...) core.root_view:on_mouse_wheel(...)
elseif type == "filedropped" then elseif type == "filedropped" then
local filename, mx, my = ... local filename, mx, my = ...
local info = system.get_file_info(filename)
if info and info.type == "dir" then
system.exec(string.format("%q %q", EXEFILE, filename))
else
local ok, doc = core.try(core.open_doc, filename) local ok, doc = core.try(core.open_doc, filename)
if ok then if ok then
local node = core.root_view.root_node:get_child_overlapping_point(mx, my) local node = core.root_view.root_node:get_child_overlapping_point(mx, my)
node:set_active_view(node.active_view) node:set_active_view(node.active_view)
core.root_view:open_doc(doc) core.root_view:open_doc(doc)
end end
end
elseif type == "quit" then elseif type == "quit" then
core.quit() core.quit()
end end