marta

Function openWithContributor()

fun marta.openWithContributor(block: (Array<FileInfo>, ActionContext) -> Array<OpenWithHandler>)

Defines an ‘Open with’ contributor.

The block will be called with an array of files for which the ‘Open with’ action is run.

Example:

openWithContributor(
    function(infos, context)
        if #infos == 1 and infos[1].pathExtension == "txt" then
            local handler = {
                name = "Open in My Precious Tool",
                priority = "low",
                apply = function(infos, context)
                    martax.alert(#infos .. "item(s) selected")
                end
            }

            return { handler }
        else
            return {}
        end
    end
)