Is there a way to focus, but not select an item in a list? + Preview Custom Column Button

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Is there a way to focus, but not select an item in a list? + Preview Custom Column Button

Post by Dustydog »

And more, is there a way to use a custom column green arrow trigger and get the value for the file on that row, even though the file has neither focus nor is selected? Just that that green arrow was pushed?
Last edited by Dustydog on 17 Apr 2017 04:43, edited 1 time in total.

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

Re: Is there a way to focus, but not select an item in a list?

Post by highend »

is there a way to use a custom column green arrow trigger and get the value for the file on that row, even though the file has neither focus nor is selected? Just that that green arrow was pushed?
cc.png
cc.png (9.69 KiB) Viewed 1080 times
Works just fine (click on any green icon to see the output in that cell). The row is neither
focused, nor selected...
One of my scripts helped you out? Please donate via Paypal

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: Is there a way to focus, but not select an item in a list?

Post by Dustydog »

Thank you for taking the time. It looks like just what I needed.

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: Is there a way to focus, but not select an item in a list?

Post by Dustydog »

Well, after your advice, highend, I tweaked one of your own scripts for use in a custom column with button. It works very well there. I use it when selecting a list of folders if I need to check contents first. And if I decide I really need to hop into one, it's certainly efficient. Thanks for your hard work - and the advice I required to tweak it :appl:

To use, put it in a custom column, similar to his picture above, only select folders instead of files, and select icon on top.

Code: Select all

/*
******************************************************************************
@SriptName: PreviewFolder.xys
@Author: Highend
@Created on: 2014-10-17 11:58:49
@Last modified: 2014-10-18 18:49:48
@Function: Preview the content of a selected folder
@Current version: v0.4
******************************************************************************
*/

    $stepIntoFolders = 1;

    $tmpScriptFile = "%TEMP%\~" . self("base") . ".xys";

    $q = chr(34);
    $lb = "<crlf>";

    // If the selected item is really a folder
    if (exists("<cc_item>") == 2) {
        // Get content and stats
        $stats   = foldersize("<cc_item>", "Stats: <d> folder(s), <f> file(s)", 0);
        $files   = listfolder("<cc_item>", , 1+4, $lb);
        $folders = listfolder("<cc_item>", , 2+4, $lb);

        // Only add entries if files or folders really exist!
        if ($files) {
            $files = regexreplace($files, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>\$1$q;$lb");
            $files = regexreplace($files, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        if ($folders) {
            if ($stepIntoFolders) {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>\$1$q;$lb");
            } else {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>$q; selectitems $q$1$q;$lb");
            }
            $folders = regexreplace($folders, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        // Different menus for empty or not empty folders
        if (regexmatches($stats, "[1-9]")) { // At least one file or folder is present
            $menuEntries = "$q$stats|:tsf$q end 1=1;$lb$q-$q$lb$folders$lb$files";
        } else {
            $menuEntries = "$q$stats|:tsf$q end 1=1;$lb$q No entries...$q";
        }

        // Write the tmp script file and load it
        writefile($tmpScriptFile, $menuEntries);
        load $tmpScriptFile;

        // Clean up
        delete 0, 0, $tmpScriptFile;
    } else {
        status "No folder selected, aborted...", "CD6600", "stop"; // Dark orange
    }

/*
******************************************************************************
@Changelog:
v0.4a
Tweaked for custom column button by Dustydog - after advice from highend, heh.
 • Switched all <curitem> to <cc_item> so button press all that required rather than selection.
 • Made stepIntoFolders default: Just because I like it, and because it makes
        the feature more obvious.
 • To get out of the preview, I've found that either ESC or clicking on the summary at
        the top of the graphic to be best. Neither accidentally deselects or toggles anything.
v0.4
 • Fixed: Display of files / folders with a leading underscore

v0.3
 • Fixed: Only add files / folders to the menu if there are any (bug)
 • Added: Option to just select or step into folders

v0.2
 • Changed: Foreach loop with regexreplace(s). Speed up by factor 10 and up

v0.1
 • COMMENT: Initial version

******************************************************************************
*/
The only possible tweak beyond this for custom column purposes, would be to make it show on button press then disappear on lift - like a preview. But I doubt it's possible. Already, it activates on button release. Great, great script, highend.

(Ofc, resize the column with the button to only button size. Then save it in a column layout. His script can really help on folders with lots of items, especially if you've got a lot of columns or you have size active.)

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

Re: Is there a way to focus, but not select an item in a list? + Preview Custom Column Button

Post by highend »

v0.5 published

Correct the typing error and uncommented the delete line for the temporary script file
Added a note for what to do to use it in a custom column
But I doubt it's possible
Correct, that's not possible ;)

Btw, one of your changes:

Code: Select all

end 1=1
end acts on a condition. You're assigning a variable here (condition checking is ==, !=, etc.)
Yeah, it works (because assigning is always TRUE) but that's not the way it's meant to be :)
One of my scripts helped you out? Please donate via Paypal

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

Re: Is there a way to focus, but not select an item in a list? + Preview Custom Column Button

Post by PeterH »

For sure, this idea would have to be
end 1==1;

But: to be simple it could be
end 1;
as 1 is the same as TRUE. (Identical!) So it's the same as
end TRUE;

(In the end: 0 or "" mean FALSE, *everything* else means TRUE.)
Win11 Pro 223H2 Gerrman

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: Is there a way to focus, but not select an item in a list? + Preview Custom Column Button

Post by Dustydog »

This is what I'm using this for at the moment. I added the MediaInfo GUI so that when using from a column on a file it gives some useful information. Thanks, highend, for a great script.

Code: Select all

/*
******************************************************************************
@ScriptName: PreviewFolder.xys
@Author: Highend
@Created on: 2014-10-17 11:58:49
@Last modified: 2017-04-17 09:16:22
@Function: Preview the content of a selected folder
@Current version: v0.5a
******************************************************************************
Lightly edited for use in a Custom Column with Button, jump active by default,
  and for use with installed GUI MediaInfo (hard path).
******************************************************************************
*/

    // 0 = Don't go into the clicked folder, but into it's parent and select it
    // 1 = Really go into the clicked folder
    $stepIntoFolders = 1;

    // Remove $RECYCLE.BIN & System Volume Information folders from the list
    $filterSystemFolders = 1;

    $tmpScriptFile = "%TEMP%\~" . self("base") . ".xys";

    $q = chr(34);
    $lb = <crlf>;

    // If the selected item is really a folder
    if (exists("<ccitem>") == 2) {
        // Get content and stats
        $stats   = foldersize(<ccitem>, "Stats: <d> folder(s), <f> file(s)", 0);
        $files   = listfolder(<ccitem>, , 1+4, $lb);
        $folders = listfolder(<ccitem>, , 2+4, $lb);

        if ($filterSystemFolders) {
            // Stats: 13 folder(s), 1 file(s)
            $countBefore = gettoken(regexmatches($stats, "\d+"), 1, "|");
            $folders     = formatlist($folders, "ef", $lb, "!$RECYCLE.BIN<crlf>System Volume Information");
            $countAfter  = gettoken($folders, "count", $lb);
            $difference  = $countBefore - $countAfter;
            if ($countBefore != $countAfter) { $stats = regexreplace($stats, "\d+ folder\(s\)", "$countAfter folder(s) [$difference hidden]"); }
        }

        // Only add entries if files or folders exist!
        if ($files) {
            $files = regexreplace($files, "^(.*?$)(\r?\n|$)", "$q$1|<ccitem>\$1$q goto $q<ccitem>\$1$q;$lb");
            $files = regexreplace($files, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        if ($folders) {
            if ($stepIntoFolders) {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<ccitem>\$1$q goto $q<ccitem>\$1$q;$lb");
            } else {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<ccitem>\$1$q goto $q<ccitem>$q; selectitems $q$1$q;$lb");
            }
            $folders = regexreplace($folders, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        // Different menus for empty or not empty folders
        if (regexmatches($stats, "[1-9]")) { // At least one file or folder is present
            $menuEntries = "$q$stats|:tsf$q end true;$lb$q-$q$lb$folders$lb$files";
        } else {
            $menuEntries = "$q$stats|:tsf$q end true;$lb$q No entries...$q";
        }

        // Write the tmp script file and load it
        writefile($tmpScriptFile, $menuEntries);
        load $tmpScriptFile;

        // Clean up
        delete 0, 0, $tmpScriptFile;
        If (exists("<curitem>") == 1) {run "C:\Program Files\MediaInfo\MediaInfo.exe" "<curitem>"}; // If a file ends up selected from jumping to it, then run MediaInfo on it. Can comment out. <-Leave these as curitem.
    } else {
        If (exists("<cc_item>") == 1) {run "C:\Program Files\MediaInfo\MediaInfo.exe" "<cc_item>"}; // If the main script didn't apply to a folder, run MediaInfo on a file. Can comment out
//        status "No folder selected, aborted...", "CD6600", "stop"; // Dark orange Can uncomment.
    }

/*
******************************************************************************
@Changelog:
v0.5
 • Changed: Filtering system folders is now an option ($filterSystemFolders)
            The stats at the top of the menu are correct accordingly when
            this option is turned on

 • Note: If you want to use the script in a custom column, just replace
         all occurrences of <curitem> with <cc_item>

v0.4
 • Fixed: Display of files / folders with a leading underscore

v0.3
 • Fixed: Only add files / folders to the menu if there are any (bug)
 • Added: Option to just select or step into folders

v0.2
 • Changed: Foreach loop with regexreplace(s). Speed up by factor 10 and up

v0.1
 • COMMENT: Initial version

******************************************************************************
*/

Post Reply