Skip to content

Instantly share code, notes, and snippets.

@958
Last active June 11, 2024 06:02
Show Gist options
  • Save 958/1797f58c312107ad6ddb26f473ab39ce to your computer and use it in GitHub Desktop.
Save 958/1797f58c312107ad6ddb26f473ab39ce to your computer and use it in GitHub Desktop.
tablacus explorer added a menu to move the selected tab to the tab group in the tab menu (Requires usloader add-on)
Sync.MoveTab = {
Exec: async function (Ctrl, pt) {
const tabs = [];
const len = await GetLength(await te.Data.Tabgroups.Data);
for (let i = 0; i < len; i++) {
const name = await te.Data.Tabgroups.Data[i].Name;
tabs.push({ index: i, name: name});
}
let hMenu = await api.CreatePopupMenu();
for (let i = tabs.length; i--;) {
let uFlags = MF_STRING;
if ((await te.Data.Tabgroups.Click - 1) == i) {
uFlags |= MF_CHECKED;
}
await api.InsertMenu(hMenu, 0, MF_BYPOSITION | uFlags, i + 1, (i+1) + ". " + tabs[i].name);
}
pt = await api.GetCursorPos();
const x = pt.x;
const y = pt.y;
const nVerb = await api.TrackPopupMenuEx(hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, ui_.hwnd, null, null);
api.DestroyMenu(hMenu);
if (nVerb > 0) {
const TCs = await te.Ctrls(CTRL_TC, false, window.chrome);
for (let i = 0; i < await TCs.length; i++) {
if (await TCs[i].Data.Group == nVerb) {
const TC = TCs[i];
const TC1 = await Ctrl;
const FV = GetFolderView(Ctrl, pt);
const index = await TC.Count;
await TC1.Move(FV.index, index, TC);
TC.SelectedIndex = index;
Addons.Tabgroups.Change(nVerb);
break;
}
}
}
}
}
AddEvent("Tabs", async function (Ctrl, hMenu, nPos) {
api.InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, ++nPos, await GetAddonInfo("tabgroups").Name);
ExtraMenuCommand[nPos] = Sync.MoveTab.Exec;
return nPos;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment