Help with Custom Toggle for Sort

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
mickey4mice
Posts: 33
Joined: 10 Oct 2011 00:05

Help with Custom Toggle for Sort

Post by mickey4mice »

Hi,

Can anyone help me create a custom button that toggles Name(ascending)/Modified(descending)?

Also, how do I assign keyboard shortcuts to easily switch between these 2 sorting?

Thanks

highend
Posts: 14566
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with Custom Toggle for Sort

Post by highend »

Save this script in your script folder (<xyscripts> in the address bar + enter)
as: SwitchSortOrder.xys

Code: Select all

    perm $P_SortOrder;
    if (!$P_SortOrder || $P_SortOrder == "m") { sortby "name", "a"; $P_SortOrder = "n"; }
    elseif ($P_SortOrder == "n") { sortby "modified", "d"; $P_SortOrder = "m"; }
    writepv;
    
- Right click on the toolbar, "Customize Toolbar..."
- Scroll down on the left side until you see the "User Buttons #<number>" buttons
- Choose the first, click on "Add ->", place it at the desired position with "Up" | "Down"
- Right click the new button on the toolbar, "Edit..."
- Choose a "Name:", evtl. an "Icon:" and in the "On left click:" field
Paste this: ::load "SwitchSortOrder.xys";
- Click "OK" and close the dialog

- Menu - User - Manage Commands...
- Click on "Load Script File" on the left side
- Click on "New..." on the upper right side
- Choose "Add New Command"
- Give it a caption, in "Script File:" enter:
SwitchSortOrder.xys
- Click on "Assign Keyboard Shortcut..." and choose one
One of my scripts helped you out? Please donate via Paypal

mickey4mice
Posts: 33
Joined: 10 Oct 2011 00:05

Re: Help with Custom Toggle for Sort

Post by mickey4mice »

highend wrote:Save this script in your script folder (<xyscripts> in the address bar + enter)
as: SwitchSortOrder.xys

Code: Select all

    perm $P_SortOrder;
    if (!$P_SortOrder || $P_SortOrder == "m") { sortby "name", "a"; $P_SortOrder = "n"; }
    elseif ($P_SortOrder == "n") { sortby "modified", "d"; $P_SortOrder = "m"; }
    
Thank you! Works perfectly.

Post Reply