Help with creating a context menu [Solved]
Posted: 22 Mar 2022 15:09
This is a script for a custom "Right-Click on White in File List" menu.
The items in the NewItems folder are assumed to be named as follows: New Markdown File, New InDesign File, and so on.
Is it possible to have the items from the NewItems folder as a part of the main pop-up menu? Like this:
I tried to replace popupnested() with popupmenu(), but then separators (that is, horizontal gray lines) were replaced to hyphens (each line to one hyphen). So it was something wrong...
Code: Select all
"Right-Click on White in File List"
$newFlags = "ru";
$cntIndent = 6;
$newItems = "";
$folders = listfolder("<xydata>\NewItems",, 2);
$files = listfolder("<xydata>\NewItems",, 1);
foreach($item, $folders . "|" . $files,, "e") {
$caption = gpc($item, "file");
$captionTrimmed = regexreplace($caption, "^New ", "");
$data = 'new("' . $caption . '"' . ((exists($item) == 2) ? ', "dir"' : ", ") . ",'" . $item . "'," . (($newFlags) ? ' "' . $newFlags . '")' : ")");
$icon = $item;
$newItems .= strrepeat(" ", $cntIndent) . $captionTrimmed . ";" . $data . ";" . $icon . <crlf>;
}
$menu =
<<<MENU
New Folder;#231
New Text File;#234
-
Refresh;#1001
-
Paste;#202
-
New
$newItems
MENU;
$selected = popupnested($menu);
if (strpos($selected, "#") != -1) { eval("""$selected"""); }
else { eval($selected); }
Is it possible to have the items from the NewItems folder as a part of the main pop-up menu? Like this:
Code: Select all
New Folder
New Text File
New Markdown File
New InDesign File
-----------
Refresh
-----------
Paste