Page 1 of 1

Help with Custom Toggle for Sort

Posted: 12 Aug 2015 07:46
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

Re: Help with Custom Toggle for Sort

Posted: 12 Aug 2015 08:28
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

Re: Help with Custom Toggle for Sort

Posted: 12 Aug 2015 20:38
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.