hi @Andreas_Hegenberg ,
current BTT version is alpha 5.498 (also tried on older versions).
I have build a script to create floating menu items that set each item the BTTMenuElementIdentifier
property of each item.
I believed I can later call update_menu_item
with menu_name and item_name, but it appears that BTT can't find menu item by their identifier.
Does floating menu dynamic creation with script takes into account the BTTMenuElementIdentifier
? I have no other way to access the menu item, as they're created dynamically, I do not have their UUID.
the script that retrieve floating menu items look like this (sorry for the code, I just show the relevant part. Note also that this code is transpiled from typescript and bundled with esbuild, this is why it looks this way)
async getItems(appConfig) {
let key_templateItemUUID = "3EB60CB2-3E6B-4363-9B27-325615AA05F8";
const baseContents = {
templateItemUUID: key_templateItemUUID,
BTTMenuItemText: ""
};
let items2 = [];
let count = 1;
for (var itemIndex = 0; itemIndex < this.FloatingMenuItemNames.length; itemIndex++) {
let contents = { ...baseContents };
let itemConfigObject = this.FloatingMenuItemNames[itemIndex];
let itemConfigObjKey = Object.keys(itemConfigObject)[0];
let itemConfig = itemConfigObject[itemConfigObjKey];
if (itemConfigObjKey == "blank_key") {
count++;
continue;
}
;
let itemName = itemConfig["key"];
let itemText = itemConfig["text"];
contents.BTTMenuItemText = itemText;
contents.BTTMenuElementIdentifier = itemName;
let appKeyMapping = this.getItemAppMapping(appConfig, itemName);
contents = { ...contents, ...appKeyMapping };
let pos = await this.ComputeItemLayout(count, itemConfig);
for (var prop in pos) {
contents[prop] = pos[prop];
}
items2.push(contents);
count++;
if (itemConfig.type != void 0 && itemConfig.type == "doubleWidth") {
count++;
}
}
return items2;
}
Basically, it creates something like this
In my workflow, I have set up a BTT trigger on "app change" that call a javascript function to update specific keys with icon and action by just calling something like
async function UpdateMenuItem(props) {
return await update_menu_item(props);
}
where props
contains an object that look like that {"menu_name":"numpad_viewer_3","item_name":"9","json":"{\"icon\":\"path::/Volumes/Travail/Programming/www/numpad/Typescript/src/icons/shortcuts/Safari/square.on.square.svg\",\"action\":\"js::(async () => {execute_assigned_actions_for_trigger({ uuid: 105AA00F-CD05-428B-B58F-AC0D42246DC7 });}\",\"BTTMenuItemBackgroundColor\":\"20, 200, 20, 255\"}","persist":true}
But nothing is updated for item "9", I suspect that BTT don't know item "9".
Thanks for your help on this.