Page 1 of 1
script to display menu
Posted: 03 Feb 2013 06:50
by kotlmg
i want to display the options of each file tab in a small menu containing the following.
name
extension
size
type
modified
created
etc.
is it possible? i require this feature because, some time file lenghth may be too much as a result i could not find modified tab until and unless i resize name tab.
thanks a lot.
Re: script to display menu
Posted: 03 Feb 2013 07:39
by highend
Code: Select all
$column = popupmenu("Name|Extension|Size|Type|Created|Modified");
if($column == "Name") {
#362;
} elseif($column == "Extension") {
#363;
} elseif($column == "Size") {
#364;
} elseif($column == "Type") {
#365;
} elseif($column == "Created") {
#366;
} elseif($column == "Modified") {
#367;
}
But why don't you just click on the column header?...
Re: script to display menu
Posted: 03 Feb 2013 14:17
by kotlmg
sir, thanks for the code.
with the above code, tabs (modified, created etc) are getting disappered. i want the files to be ordered by the selected options( name,size, modfied, created, extension etc). i don't want their column names to get disappeared.
Re: script to display menu
Posted: 03 Feb 2013 14:59
by highend
file lenghth may be too much as a result i could not find modified tab until and unless i resize name tab
No single word about ordering by column header entry...
Just look up the correct ids in the keyboard shortcuts configuration dialog...
Re: script to display menu
Posted: 03 Feb 2013 15:25
by kotlmg
as per your guidance, i have modified the code as
$column = popupmenu("Name|Extension|Size|Type|Created|Modified");
if($column == "Name") {
#321;
} elseif($column == "Extension") {
#322;
} elseif($column == "Size") {
#323;
} elseif($column == "Type") {
#324;
} elseif($column == "Created") {
#325;
} elseif($column == "Modified") {
#326;
}
and it is working perfectly. thank you.
Re: script to display menu
Posted: 03 Feb 2013 18:09
by calude
Thanks HighEnd
Very Useful
Calude
Re: script to display menu
Posted: 03 Feb 2013 21:38
by PeterH
Just as a tip: you can shorten this to:
Code: Select all
$column = popupmenu("Name|Extension|Size|Type|Created|Modified");
if($column == "Name") { #321; }
if($column == "Extension") { #322; }
if($column == "Size") { #323; }
if($column == "Type") { #324; }
if($column == "Created") { #325; }
if($column == "Modified") { #326; }
Reason: $column can only match one value of the if-group.
2nd reason: it can be read and understood much faster this way
(OK: I would also align the
) { #...; } - but that's a matter of taste

)
Re: script to display menu
Posted: 04 Feb 2013 17:39
by TheQwerty
Time for a little code golf?
If you really do want to customize/minimize the column choices...
Code: Select all
SortBy PopupMenu('Name|Extension|Size|Type|Created|Modified'), 'clk';
Otherwise...
Code: Select all
#320; //View | Sort By | - submenu -

Re: script to display menu
Posted: 04 Feb 2013 18:51
by PeterH
TheQwerty wrote:Time for a little code golf?
If you really do want to customize/minimize the column choices...
Code: Select all
SortBy PopupMenu('Name|Extension|Size|Type|Created|Modified'), 'clk';

-
That's fine

Re: script to display menu
Posted: 26 Oct 2020 19:16
by WirlyWirly
Nearly a decade later, this information is still gold! I'm trying to apply the same concept to View options, but for some reason when the command executes it quickly flashes the change then reverts to my default folder view. Any ideas what I'm doing wrong? I was looking through the docs, but I couldn't find a
Sortby equivalent for view options...
Code: Select all
/*
A collection of the most-used right-click options...
*/
$menu = <<<MENU
0) Sort by...||
0) Date Modified|Sortby 'Modified', 'clk'|
1) Extension|Sortby 'Ext', 'clk'|
2) Size|Sortby 'Size', 'clk'|
3) Type|Sortby 'Type', 'clk'|
4) Date Created|Sortby 'Created', 'clk'|
1) View..||
0) Thumbnails Small|#306|
1) Thumbnails Medium|#307|
2) Thumbnails Large|#308|
3) List|#304|
4) Details + Thumbnails|#303|
2) Copy..||
0) Absolute path(s)|//placeholder|
1) Absolute Unix-style path(s)|//placeholder|
2) Absolute Parent path|//placeholder|
MENU;
// Get X/Y position of a control
$position = controlposition('A', 0);
$x_pos = gettoken($position, 1, '|');
$y_pos = gettoken($position, 2, '|');
// Display the context menu
$command = popupnested($menu, $x_pos, $y_pos,,,,,|);
// Run the selected command
if ($command != '') { load $command,, s; }
Edit
Figured it out. The last line where I load $command gets screwy if using ID's. Unlike other commands that are returned as strings, ID's seem to get executed immediately. I'm going to have to parse the $command variable to see if it was an ID, and if it true skip the load block since the action was already performed. Thanks again for the instruction!
Code: Select all
// Run the selected command
if ($command != '') {
if (regexmatches($command, '^\#\d+$') == '') { load $command,, s; }
}
Re: script to display menu
Posted: 26 Oct 2020 20:13
by highend
Code: Select all
if ($command && !regexmatches($command, '^\#\d+$')) { load $command,, s; }