macos: support drag-and-drop and default file associations (#1822)

* macos: support drag-and-drop and default file associations

* resources/macos: use LSItemContentTypes to narrow down files

* macos: support opening folders

* rootview: workaround macos weird dnd event timing

* core/rootview: rename variable and refactor if statement
This commit is contained in:
Takase
2024-06-23 10:08:08 +08:00
committed by takase1121
parent 214602d17a
commit ce70fcf5dd
3 changed files with 51 additions and 17 deletions
+1 -14
View File
@@ -1272,20 +1272,7 @@ function core.on_event(type, ...)
elseif type == "minimized" or type == "maximized" or type == "restored" then
core.window_mode = type == "restored" and "normal" or type
elseif type == "filedropped" then
if not core.root_view:on_file_dropped(...) then
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)
if ok then
local node = core.root_view.root_node:get_child_overlapping_point(mx, my)
node:set_active_view(node.active_view)
core.root_view:open_doc(doc)
end
end
end
core.root_view:on_file_dropped(...)
elseif type == "focuslost" then
core.root_view:on_focus_lost(...)
elseif type == "quit" then