script to display menu

Discuss and share scripts and script files...
Post Reply
kotlmg
Posts: 298
Joined: 30 Jun 2010 17:14

script to display menu

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: script to display menu

Post 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?...
One of my scripts helped you out? Please donate via Paypal

kotlmg
Posts: 298
Joined: 30 Jun 2010 17:14

Re: script to display menu

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: script to display menu

Post 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...
One of my scripts helped you out? Please donate via Paypal

kotlmg
Posts: 298
Joined: 30 Jun 2010 17:14

Re: script to display menu

Post 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.

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to display menu

Post by calude »

Thanks HighEnd
Very Useful
Calude

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: script to display menu

Post 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 :D

(OK: I would also align the ) { #...; } - but that's a matter of taste :P )
W7(x64) SP1 German
( +WXP SP3 )

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: script to display menu

Post 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 -
:whistle:

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: script to display menu

Post 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';
:shock: - :appl: :appl: :appl:

That's fine :D
W7(x64) SP1 German
( +WXP SP3 )

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: script to display menu

Post 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! :oops:

Code: Select all

    // Run the selected command
    if ($command != '') {
        if (regexmatches($command, '^\#\d+$') == '') { load $command,, s; }
    }

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: script to display menu

Post by highend »

Code: Select all

if ($command && !regexmatches($command, '^\#\d+$')) { load $command,, s; }
One of my scripts helped you out? Please donate via Paypal

Post Reply