am trying to create a floating menu window/box that accepts a dropped item (ex. a link), then run a script with that item.
i tried with the notch example but i dont know what am doing exactly and how to get the drop to work correctly.
am trying to create a floating menu window/box that accepts a dropped item (ex. a link), then run a script with that item.
i tried with the notch example but i dont know what am doing exactly and how to get the drop to work correctly.
I have just updated the drop behavior today. Previously only dropping files was possible, now all kind of things can be dropped. You need at least BTT 5.355 alpha. I still need to document it however.
Everything dropped onto an item can be retrieved via get_menu_item_value either from Apple Script or (better) BTT's Java Script
The dropped items are available in all representations provided by the system in a JSON object. For example:
{
"public.html": [{
"uti": "public.html",
"type": "text",
"value": "<b>Hello</b>",
"timestamp": "2025-05-04T21:00:00Z"
}],
"public.file-url": [{
"uti": "public.file-url",
"type": "file",
"value": "/Users/you/Desktop/file.txt",
"timestamp": "2025-05-04T21:00:00Z"
}]
}
Here is a example preset:
drop-example.bttpreset (19.2 KB)
async function getDrops() {
let dropJSONString = await get_menu_item_value( {itemUUID: "76DBA7CD-B472-4E3C-BC6B-8AA1CA922BE9"});
// parse the saved string into a Java Script object:
let itemVal = JSON.parse(dropJSONString);
// setting it on the text area item, so we can view the dropped content
await set_menu_item_value( {itemUUID: "50C1D052-2B39-4D24-806B-39273974C0C8", 'value': JSON.stringify(itemVal, null, 2)});
// example of how you would access a dropped url:
return itemVal["public.url"][0]["value"];
}