Tab changes

Discuss and share scripts and script files...
Post Reply
klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Tab changes

Post by klownboy »

I've recently started asking myself when changing tabs in XYplorer, why am I looking at the Navigation Panel and tree when I'm looking at photos, PDF files, Icons, or wallpapers. It didn't make sense in many cases. So, I came up with a minor script which uses the tab IDs of those tabs that I don't need to see the tree / Nav panel. I obtained the tab IDs of those tabs that I really don't need to see an Nav Panel. Very easy to do - just press the shift key and then float your mouse cursor over the tab (label). Write them down, and then insert your own tab IDs in the script's first line in lieu of my own or if you use dual pane substitute your numbers (tab IDs) for $tokenlist_p1 in the dual pane version. If you use dual pane, do the same for pane 2. Write the tab IDs and substitute those numbers in the dual pane version as $tokenlist_p2.
Put the script in the script section in Configuration > Custom Event Actions for the event "Switch tabs" or, save the above script as a script file (recommended especially if using dual pane) naming it "TabChanges.xys" (or whatever and place that in the script section by adding, load "<xyscripts>\TabChanges.xys"; Remember to set the "Action" block to Run script.

If you use dual pane I recommend you use the dual pane version and save the script as a script file BECAUSE if you use dual pane we have to know when you change panes as well as change tabs. Therefore, you have to add the same script not only for CEA for "Switch tabs" but also "Switch panes". So, it makes it easier to simply add the one liner to load the script file under the CEA for "Switch panes" as you did for "Switch tabs" rather than the repeating the whole script. If the script is not placed in "Switch panes" as well, the pane change will not reflect the proper tab Nav panel condition, but instead inherits the one from the previous pane.

I know it's easy to hit the Nav Panel On / Off key, F8 or whatever you have assigned to it, but I wanted it done automatically. You could do something similar or other actions based on the "View" or something else if you wanted. Just isolate what tabs via the tab IDs. I didn't use tab indexes since those can be fiddled with based on position.

Yes, I could use a more elaborate script like Session Manager or loading layouts or similar to do this, but in this case all I really need was to show or hide the Nav Panel - simple as that.

Don, whether to show the Navigation Panel a for a particular tab may actually be a nice option built directly in to the tabs's right click menu. The script is fast but an tab specific option would be a good deal.

Thanks jupe for your comment on use with dual panes.
Use the following if you only use one pane :

Code: Select all

  if(gettokenindex(tab("get","ID"), "4|5|13|18|19|22", "|", "")) {  //for tabs that you don't want the Nav panel
    if(get("#663")) {#663; end 1;} //if Nav panel is active, hide it
    else {end 1;}                  //if Nav panel is not active, exit script
  }
 else {                  // for tabs that you want a Nav panel 
    if (!get("#663")) {#663; end 1;} // Nav Panel is not active so add it
    else {end 1;}          // Nav Panel is active so end script
  }
Use this version if you are a dual pane user:

Code: Select all

  $tokenlist_p1 = "4|5|6|13|18|19|20|22"; // substitute your list of tabs for pane 1 here
  $tokenlist_p2 = "2|4|5|7";              // substitute your list of tabs for pane 2 here
  $tokenlist = (get("pane") == "1")?$tokenlist_p1:$tokenlist_p2;
  if(gettokenindex(tab("get","ID"), $tokenlist, "|", "")) {  //for tabs that you don't want the Nav panel
    if(get("#663")) {#663; end 1;} //if Nav panel does not exist activate it
    else {end 1;}                  //if Nav panel is not active ,exit script
  }
 else {                  // for tabs that you want a Nav panel 
    if (!get("#663")) {#663; end 1;} // Nav Panel is not active so add it
    else {end 1;}          // Nav Panel is active so end script
  }
Last edited by klownboy on 04 Feb 2024 17:20, edited 1 time in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

jupe
Posts: 2805
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Tab changes

Post by jupe »

Does this work as you expect on Pane 2?, because the tabID's are per pane.

klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Re: Tab changes

Post by klownboy »

Honestly jupe, on most occasions I only use one pane so I hadn't looked at pane 2 use. Though I don't imagine it would be too difficult to set it up for two panes or the other pane use. I would have to start by checking if we were in dual pane mode and if we were, determine which pane has the focus or if we were in single pane mode which pane has the focus. The user would still have to establish which tab IDs they wanted to have no Nav panel, but for both panes. It would probably be best to set the pane 1 and pane 2 sets of tab IDs (i.e., the token lists) as variables and depending on which pane has focus use the appropriate variable. I'll look into it tomorrow. Thanks.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

jupe
Posts: 2805
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Tab changes

Post by jupe »

Yeah I thought you must use only 1 pane, I only mentioned it because if new users try using it, they may need help modifying it if they don't want the nav panel disappearing unexpectedly when on pane2.

klownboy
Posts: 4142
Joined: 28 Feb 2012 19:27

Re: Tab changes

Post by klownboy »

Thanks again jupe for your comment on use with dual panes. I modified the first post to provide a dual pane version or I should say a version that works whether you use dual pane or not.

One thing I noticed in the last few weeks before I posted the original script, I've been seeing some tabs changing locations. Which must mean the index(es) must be changing of course the tab ID will not. I'm quite sure it has nothing to do with this script in any case. It seems to take place whether I'm using wide tab bar setting in Window > Arrangements or not (I typically do not use wide tabs). It's a little annoying honestly. A while back I noticed an issue with tabs that was due to running out of space at the end of the tab bar (i.e., I have bold active tab on and in some cases that will increase the size of the tab and I'd run out of space so a front or left most tab would be off screen). That issue was explained by Don here viewtopic.php?t=26981 But, my tabs changing location now is not due to that; I have plenty of tab space. I'm not sure if it may be a bug going on. Anyone else experience anything similar or any thoughts?
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply