Page 1 of 1

Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 12:32
by cadu
Hi,
Besides the default menus as showed in this snapshot (http://i.imgur.com/jSt58qd.png), can XYplorer create custom menus?
Besides the default toolbar, can XYplorer create a custom toolbar?
For instance, I would like to create a menu and/or toolbar with the features I use most, or features that I use in very specific cases, etc.
If there is no way to create custom menus/toolbar, is there any workaround to assemble/join/organize features in some kind of interface/list/etc.
Thanks,
Carlos

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 12:41
by highend
Menus (visible in the normal menu bar)? No
As dropdown menus? Scripting...
Toolbars? Scripting...

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 12:51
by cadu
highend wrote:Menus (visible in the normal menu bar)? No
As dropdown menus? Scripting...
Toolbars? Scripting...
Thanks for reply. I've never used scripts.
Could you please just provide a template on how to implemente 1 single item (e.g. "branch view") through a "dropdown menus" and through a "Toolbar"?
From this template I'm sure I can go ahead.
Many thanks for assistance,
Carlos

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 13:13
by highend

Code: Select all

    $menus = <<<>>>
Branch view;#311
>>>;
    load popupmenu($menus, , , , , , <crlf>), , "s";

Code: Select all

    $toolbars = <<<>>>
Default;back,fore,up,refresh,-,exitnosave
Branch view;flatview
>>>;
    toolbar(popupmenu($toolbars, , , , , , <crlf>));
DO NOT SAVE YOUR SETTINGS before you didn't specify your "Default" toolbar correctly!

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 14:37
by cadu
Hi highend,

Many thanks for sharing the scripts.

I would appreciate a further help from you, and I would be glad to donate a fair amount for your assistance.

I recorded my screen showing the following issues below in details: https://goo.gl/Zu4T3F

Regarding the custom Menu:

a) After creating the custom scrip menu, I can access it just through Scripting>Load Script File. How to set the script to be triggered both through a shortcut? Actually, I could insert the scrip as a "user button", what is a step ahead, but the shortcut is still missing.

b) How to add a separator line between custom menu items?

c) When I click out of the menu there is a code screen which pops-up. I would prefer that clicking out of the menu simply doesn't run any command and close the menu.

Regarding the custom Toolbar:

d) You warned: "DO NOT SAVE YOUR SETTINGS before you didn't specify your "Default" toolbar correctly!". How to set the "Default" toolbar?

Thank you!
Carlos

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 15:52
by highend
a.) You can either load the script via
Menu - User - Manage Commands...

Category: Load Script File
Right upper side: "New..." Button -> Add new command
Caption: <however you want to name it>
Script File: <the path to your .xys script>, e.g.: D:\Temp\Menu.xys

And when done, on the bottom "Assign Keyboard Shortcut"

==================================================

It's nearly the same if you've chosen to use a user button in the toolbar
Look up how the button you want to execute / clicked is named
Ctrl + Right click on any toolbar icon -> Customize Toolbar...
In the right list, look what's in the [...] part of that specific
button

Let's say it's: [ctb7]
Here it's the name of a custom button...

Now:
Menu - User - Manage Commands...

Category: Run Script
Right upper side: "New..." Button - Add new command
Caption: <whatever>
Script: button "ctb7";

Code: Select all

button "ctb7";
Is the script command that you want to get executed. It emulates a mouse click
on that specific button...

And when done, on the bottom "Assign Keyboard Shortcut"


b.)
It's a simple "-" but without the quotation marks
Like

Code: Select all

    $toolbars = <<<>>>
Default;back,fore,up,refresh,-,exitnosave
-
Branch view;flatview
>>>;

c.)
Change it like this:

Code: Select all

    $menus = <<<>>>
Branch view;#311
>>>;
    $selected = popupmenu($menus, , , , , , <crlf>);
    if ($selected) { load $selected, , "s" }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }
You can leave out the else... line if you want

The same principle can be used for the toolbar code as well


d.)
Execute this from the address bar:

Code: Select all

text toolbar();
This gives you the ,-separated list of the currently defined items on your toolbar.
Let's say you get:
back,fore,-,myco,hotlist,openwith,-,ctb2,ctb3,ctb17,-,ctb4,ctb12,-,ctb6,ctb7,-,ctb1,ctb11,ctb18,ctb13,ctb14,ctb15,ctb16,-,undo,redo,-,ctb8,-,cofi,tsf,visualfilter,icf,cucopy,-,ctb9,-,conf,savesett
Then you do it like this:

Code: Select all

    $toolbars = <<<>>>
Default;back,fore,-,myco,hotlist,openwith,-,ctb2,ctb3,ctb17,-,ctb4,ctb12,-,ctb6,ctb7,-,ctb1,ctb11,ctb18,ctb13,ctb14,ctb15,ctb16,-,undo,redo,-,ctb8,-,cofi,tsf,visualfilter,icf,cucopy,-,ctb9,-,conf,savesett
-
Branch view;flatview
-
Another entry;<name of the toolbar button>
>>>;
    $selected = popupmenu($toolbars, , , , , , <crlf>);
    if ($selected) { toolbar($selected); }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 20:21
by cadu
Hi highend,

Many thanks for further explanation. Actually, there is a couple of points still a bit unclear:

a) Regarding set default toolbar, that last code you shared, should I run that as a script or paste in the field which appears after running the command "text toolbar();"? I recorded my screen detailing my question: https://goo.gl/fUxyux

b) Regarding the custom menu, is there any way the items there reflect the state of the command? For instance, if I used the command "View details;#302", and this view is on, so the respective custom menu item should be showed checked. In other words, if your list is set as "details", you go to menu>view>views>details, and details is checked. I recorded my screen detailing my question: https://goo.gl/wXjFwm

c) Regarding the custom menu, I just checked a thread in which the items in the menu are showed having their respective icons (http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=14409). Currently, this is my trial custom menu script:

Code: Select all

$menus = <<<>>>
New Folder;#231
Branch view;#311
View details;#302
-
Checkbox selection;#415
>>>;
    $selected = popupmenu($menus, , , , , , <crlf>);
    if ($selected) { load $selected, , "s" }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }
Is it possible to improve this script in order to show the icons of menu items, similarly to that thread reference?

Thanks!

Re: Can XYplorer create custom menus or toolbars?

Posted: 23 Jan 2017 21:42
by highend
a.) text toolbar();
Gives you your current items in the toolbar in a ,-separated format

So paste that in your toolbar.xys script (or however you named it) right behind the ; for the Default entry.
Look at the part between <> brackets...

Code: Select all

    $toolbars = <<<>>>
Default;<paste the content from the text box that appeared after executing the text toolbar(); command here>
-
<other toolbar items...>
>>>;
    $selected = popupmenu($toolbars, , , , , , <crlf>);
    if ($selected) { toolbar($selected); }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }

b.) Sure, but his requires a bit more coding...
Be careful, this toolbar.xys script must be in a file (otherwise you'd need to adapt it to read/write the changes
to the state flag (checked/disabled) to an .ini file...) and NOT inside the script field of a button / user defined
command....

This version modifies itself on each run when an item is chosen!

E.g.:

Code: Select all

    // Caption;Data;Icon;State(2=checked,4=disabled)
    $toolbars = <<<>>>
Default;back,fore,-,myco,hotlist,openwith;;0
Branch view;flatview;;0
Test1;flatview;;2
>>>;
    $toolbars = formatlist($toolbars, "e", <crlf>);

    $newToolbars = "";
    $index = popupmenu($toolbars, , , , , 1);
    if ($index) {
        while ($i++ < gettoken($toolbars, "count", <crlf>)) {
            $line = gettoken($toolbars, $i, <crlf>);
            switch (gettoken($line, "count", ";")) {
                case 3: $line = $line . ";"; break;
                case 2: $line = $line . ";;"; break;
            }
            $newToolbars = $newToolbars . gettoken($line, 3, ";", , 1) . (($i == $index) ? ";2" : ";0") . <crlf>;
        }
        $newToolbars = formatlist($newToolbars, "e", <crlf>);
        // Rewrite own file
        $ownFile = self("path") . "\" . self("base") . ".xys";
        $content = regexreplace(readfile($ownFile), "([ ]*\$)(toolbars = <<<>>>)([\s\S]+?)(>>>;)", "$1$2<crlf>$newToolbars<crlf>$4");
        writefile($ownFile, $content);
        toolbar(gettoken(gettoken($newToolbars, $index, <crlf>), 2, ";"));
    } else { status "No item chosen, aborted!", "8B4513", "stop"; }
Here is a version, that uses an .ini file in the same folder where the script resides:

Code: Select all

    $iniFile = self("path") . "\" . self("base") . ".ini";
    if !(exists($iniFile)) {
        writefile($iniFile, "[Toolbars]<crlf>1=Default;" . toolbar() . "<crlf>2=Edit_the_ini_file_now;...", , "tu");
    }
    $entries = formatlist(regexreplace(getsectionlist("Toolbars", $iniFile), "^\d+="), "e", <crlf>);

    // Caption;Data;Icon;State(2=checked,4=disabled)
    $newEntries = "";
    $index = popupmenu($entries, , , , , 1);
    if ($index) {
        while ($i++ < gettoken($entries, "count", <crlf>)) {
            $line = gettoken($entries, $i, <crlf>);
            switch (gettoken($line, "count", ";")) {
                case 3: $line = $line . ";"; break;
                case 2: $line = $line . ";;"; break;
            }
            $newEntries = $newEntries . "$i=" . gettoken($line, 3, ";", , 1) . (($i == $index) ? ";2" : ";0") . <crlf>;
        }
        $newEntries = formatlist($newEntries, "e", <crlf>);
        // Write to .ini file
        writefile($iniFile, "[Toolbars]<crlf>$newEntries", , "tu");
        toolbar(gettoken(gettoken($newEntries, $index, <crlf>), 2, ";"));
    } else { status "No item chosen, aborted!", "8B4513", "stop"; }

c.)
Sure, you'd only need to add the appropriate item in the third place on each line for the $menus variable

These entries (":newfolder") are internal XY icon names. Ofc you could also use real icons but
you need to insert them with their full path (or use XY environment variables) when they are not
in the same folder as the script...

E.g.:

Code: Select all

$menus = <<<>>>
New Folder;#231;:newfolder
Branch view;#311;:flatview
View details;#302;:viewdetails
-
Checkbox selection;#415
>>>;
    $selected = popupmenu($menus, , , , , , <crlf>);
    if ($selected) { load $selected, , "s" }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }

You can see most icons and their internal name with this script:

Code: Select all

":autorefresh|:autorefresh" CopyText Self(icon);
":backupto|:backupto" CopyText Self(icon);
":back|:back" CopyText Self(icon);
":bfop|:bfop" CopyText Self(icon);
":browsenetwork|:browsenetwork" CopyText Self(icon);
":calcfosi|:calcfosi" CopyText Self(icon);
":cat|:cat" CopyText Self(icon);
":cfi|:cfi" CopyText Self(icon);
":cks|:cks" CopyText Self(icon);
":clip|:clip" CopyText Self(icon);
":closetab|:closetab" CopyText Self(icon);
":cofi|:cofi" CopyText Self(icon);
":conf|:conf" CopyText Self(icon);
":copypath|:copypath" CopyText Self(icon);
":copyto|:copyto" CopyText Self(icon);
":copy|:copy" CopyText Self(icon);
":ctb1|:ctb1" CopyText Self(icon);
":cucopy|:cucopy" CopyText Self(icon);
":cut|:cut" CopyText Self(icon);
":del|:del" CopyText Self(icon);
":dosbox|:dosbox" CopyText Self(icon);
":dp1|:dp1" CopyText Self(icon);
":dp2|:dp2" CopyText Self(icon);
":dpcopyto|:dpcopyto" CopyText Self(icon);
":dpmoveto|:dpmoveto" CopyText Self(icon);
":dp|:dp" CopyText Self(icon);
":drives|:drives" CopyText Self(icon);
":exitnosave|:exitnosave" CopyText Self(icon);
":favfiles|:favfiles" CopyText Self(icon);
":favs|:favs" CopyText Self(icon);
":findlabel|:findlabel" CopyText Self(icon);
":find|:find" CopyText Self(icon);
":flatview|:flatview" CopyText Self(icon);
":fore|:fore" CopyText Self(icon);
":fp|:fp" CopyText Self(icon);
":fvs|:fvs" CopyText Self(icon);
":goprev|:goprev" CopyText Self(icon);
":go|:go" CopyText Self(icon);
":grid|:grid" CopyText Self(icon);
":hidenav|:hidenav" CopyText Self(icon);
":hightree|:hightree" CopyText Self(icon);
":home|:home" CopyText Self(icon);
":hotlist|:hotlist" CopyText Self(icon);
":icf|:icf" CopyText Self(icon);
":labels|:labels" CopyText Self(icon);
":lasttarget|:lasttarget" CopyText Self(icon);
":locktab|:locktab" CopyText Self(icon);
":lstmgmt|:lstmgmt" CopyText Self(icon);
":meta|:meta" CopyText Self(icon);
":minitree|:minitree" CopyText Self(icon);
":moveto|:moveto" CopyText Self(icon);
":mru|:mru" CopyText Self(icon);
":myco|:myco" CopyText Self(icon);
":netmap|:netmap" CopyText Self(icon);
":netunmap|:netunmap" CopyText Self(icon);
":newfolder|:newfolder" CopyText Self(icon);
":newtab|:newtab" CopyText Self(icon);
":nuke|:nuke" CopyText Self(icon);
":openwith|:openwith" CopyText Self(icon);
":panellast|:panellast" CopyText Self(icon);
":panelmax|:panelmax" CopyText Self(icon);
":panelshow|:panelshow" CopyText Self(icon);
":paper|:paper" CopyText Self(icon);
":paste|:paste" CopyText Self(icon);
":previewfull|:previewfull" CopyText Self(icon);
":preview|:preview" CopyText Self(icon);
":props|:props" CopyText Self(icon);
":qfv|:qfv" CopyText Self(icon);
":qns|:qns" CopyText Self(icon);
":queue|:queue" CopyText Self(icon);
":redo|:redo" CopyText Self(icon);
":refreshsus|:refreshsus" CopyText Self(icon);
":refresh|:refresh" CopyText Self(icon);
":rename|:rename" CopyText Self(icon);
":rfo|:rfo" CopyText Self(icon);
":savesett|:savesett" CopyText Self(icon);
":select|:select" CopyText Self(icon);
":shellprops|:shellprops" CopyText Self(icon);
":showfolders|:showfolders" CopyText Self(icon);
":showhidden|:showhidden" CopyText Self(icon);
":showsystem|:showsystem" CopyText Self(icon);
":sort|:sort" CopyText Self(icon);
":steps|:steps" CopyText Self(icon);
":sticky|:sticky" CopyText Self(icon);
":stop|:stop" CopyText Self(icon);
":syncscroll|:syncscroll" CopyText Self(icon);
":tablist|:tablist" CopyText Self(icon);
":tabsets|:tabsets" CopyText Self(icon);
":tagsadd|:tagsadd" CopyText Self(icon);
":tagsfind|:tagsfind" CopyText Self(icon);
":tagsrmv|:tagsrmv" CopyText Self(icon);
":tagsset|:tagsset" CopyText Self(icon);
":tpt|:tpt" CopyText Self(icon);
":treeshow|:treeshow" CopyText Self(icon);
":tsf|:tsf" CopyText Self(icon);
":udc|:udc" CopyText Self(icon);
":undo|:undo" CopyText Self(icon);
":up|:up" CopyText Self(icon);
":viewdetails|:viewdetails" CopyText Self(icon);
":viewlist|:viewlist" CopyText Self(icon);
":views|:views" CopyText Self(icon);
":viewthumbs|:viewthumbs" CopyText Self(icon);
":visualfilter|:visualfilter" CopyText Self(icon);
":wipe|:wipe" CopyText Self(icon);
":zoomin|:zoomin" CopyText Self(icon);
":zoomout|:zoomout" CopyText Self(icon);


Re: Can XYplorer create custom menus or toolbars?

Posted: 24 Jan 2017 15:50
by cadu
Thanks for all your support highend!
I hope my donation has reached you already.
Cheers,
Carlos

Re: Can XYplorer create custom menus or toolbars?

Posted: 24 Jan 2017 16:45
by highend
Got it, thanks!

Re: Can XYplorer create custom menus or toolbars?

Posted: 20 Oct 2018 10:12
by cadu
Hi! I would appreciate help.
Regarding the script, it seems to be triggering the commands twice.
I mean, it runs the command as expected. Then after using the command, it will be triggered another time automatically. This last step shouldn't happen.
I recorded my screen showing the issue (https://drive.google.com/open?id=1F289M ... A5eIes07BZ).
Is it indeed a script issue?
Thank you very much!

This is my current variation of the script

Code: Select all

$menus = <<<>>>
Configuration;#600;:conf
Shortcuts;#602
List Management;#610;:lstmgmt //Shortcuts;#602;:cks
User > Manage Commands...;#656
-
Save settings;#182;:savesett
Exit without saving;#191;:exitnosave //Refresh;#1001;:refresh
Update;#711
-
Manage Favorite Folders...;#574
Manage Favorite Files...;#575
-
Tabset: Save;#852;:tabsets
Tabset: Save as;#853;:tabsets
Tabset: Rename;#855;:tabsets
Tabset: Go to folder;#858;:tabsets
-
Tree;#668;:treeshow
Mini Tree;#489;:minitree
Load Favorite Tree;#516
Set Favorite Tree;#515
-
Optimize Tree;#1040
Collapse;#1009
Hide Folder;#514
Path Tracing;#419
-
Define View as default;#476
-
Thumbnails;#310
Cache;#500
>>>;
    $selected = popupmenu($menus, , , , , , <crlf>);
    if ($selected) { load $selected, , "s" }
    else { status "No item chosen, aborted!", "8B4513", "stop"; }

Re: Can XYplorer create custom menus or toolbars?

Posted: 21 Oct 2018 08:45
by highend
I don't know why the selected entry gets executed a second time... The script itself only does it once, other wise it would popup the menu a second time as well. Can't do any testing here atm, no computer with XY around till next sunday...

Re: Can XYplorer create custom menus or toolbars?

Posted: 21 Oct 2018 14:41
by jupe
When using command IDs in a popupmenu it is a special case and they are executed directly, their states are shown in the menu etc. so a working version of your script doesn't need code to execute the commands if you are using IDs for them all, as you are in this case. So for example this would work:

Code: Select all

    $menus = <<<>>>
Configuration;#600;:conf
Shortcuts;#602
List Management;#610;:lstmgmt //Shortcuts;#602;:cks
User > Manage Commands...;#656
-
Save settings;#182;:savesett
Exit without saving;#191;:exitnosave //Refresh;#1001;:refresh
Update;#711
-
Manage Favorite Folders...;#574
Manage Favorite Files...;#575
-
Tabset: Save;#852;:tabsets
Tabset: Save as;#853;:tabsets
Tabset: Rename;#855;:tabsets
Tabset: Go to folder;#858;:tabsets
-
Tree;#668;:treeshow
Mini Tree;#489;:minitree
Load Favorite Tree;#516
Set Favorite Tree;#515
-
Optimize Tree;#1040
Collapse;#1009
Hide Folder;#514
Path Tracing;#419
-
Define View as default;#476
-
Thumbnails;#310
Cache;#500
>>>;
    popupmenu($menus, , , , , , <crlf>);
You can paste the following into the XY address bar for more information if you are interested:

Code: Select all

::help "idh_scripting_comref.htm#idh_sc_popupmenu";
Look under the "Adding XYplorer Menu Commands and Toolbar Buttons" heading.

Re: Can XYplorer create custom menus or toolbars?

Posted: 22 Oct 2018 11:03
by cadu
Thank you very much for the reply!
Problem solved.