i just want a toggle button (i've searched)

Features wanted...
Post Reply
CISplorer
Posts: 8
Joined: 11 May 2017 10:20

i just want a toggle button (i've searched)

Post by CISplorer »

so, i just want a button to toggle between #304 and #307 on left click. I've searched, I've read things about making a script and loading it. In edit button I've put #304 in left click (and it works) but #307 in right click doesn't. But i just want the left click toggle option anyways. please and thank you.

all the view toggle buttons go from details to other option, why always details?

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: i just want a toggle button (i've searched)

Post by bdeshi »

use this for the left-click:

Code: Select all

if get('view') != 2 { #304; } else { #307; }
get('view') returns current view mode as an integer. The code snippet translates to:
"if viewmode is not 2 (list), then switch to List view [#304], otherwise switch to Thumbs#2 view [#307]."

This has one unhandled case: if the view mode is neither List nor Thumbs #2, this will switch to List.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

CISplorer
Posts: 8
Joined: 11 May 2017 10:20

Re: i just want a toggle button (i've searched)

Post by CISplorer »

Thank you so much, i sincerely appreciate your help. exactly what i wanted. but just for icing on the cake, how would i get the right click menu that exists on the pre-made toolbar view buttons? and how could i access the current icons so i could create a half list half thumbs icon?

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

Re: i just want a toggle button (i've searched)

Post by klownboy »

The following line will bring up the right click "Views" menu if you place it in the Right click edit box of your CTB.

Code: Select all

button "views", 2
You are welcome to try this old script, ViewSwitcher.xys that I've used for years. It could stand an update, but it works and the icon changes to reflect the view mode. Left click of the assigned CTB cycles between List view and Detail view and the Right click cycles between Details and Thumbnail view.

Code: Select all

    $View = get("View");
 if (<get trigger> == 1) {

   if (ctbicon() != ":viewlist" AND $View != 2) { 
     ctbicon(":viewlist");
     ctbstate(0);
     #304;                      // go to List view                   
   } else {                     // if list go to Detail view
     ctbicon(":viewdetails");
     ctbstate(1);
     #302; }
  end 1;
  }

 if (<get trigger> == 2) {
      if ($View <= 3) {
        ctbicon(":viewthumbs");
        ctbstate(1);
        #308; }
     elseif ($View >= 4) { 
        ctbicon(":viewdetails");
        ctbstate(0);
        #302; }
    else {
        ctbstate(0);
        #478; }
    end 1;
   }

   
To use the script put load "<xyscripts>\ViewSwitcher.xys"; in both the left and right click edit boxes of a CTB. Feel free to modify it to change view modes to what you would like or anything else.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: i just want a toggle button (i've searched)

Post by klownboy »

I didn't have much time, but the following may be a bit closer to what you were looking for. Left click toggles between list and thumbnail views and the Right click brings up the Views right click menu. The icon / state will change with the view, but if go to a different folder in a different view mode the icon will be off for a click or two but it will sync.

Code: Select all

    $View = get("View");
 if (<get trigger> == 1) {
   if (ctbicon() != ":viewlist" AND $View != 2) {
     ctbicon(":viewlist");
     ctbstate(0);
     #304;                      // go to List view                   
   } else {                     // if list go to Thumbnail view
     ctbicon(":viewthumbs");
     ctbstate(1);
     #307; }
  end 1;
  }

 if (<get trigger> == 2) {
	button "views", 2;
	end 1;
   }
As I said above, to use the script enter load "<xyscripts>\ViewSwitcher.xys"; in both the left and right click edit boxes of a CTB.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

CISplorer
Posts: 8
Joined: 11 May 2017 10:20

Re: i just want a toggle button (i've searched)

Post by CISplorer »

wow, that is more than i thought i could do. thank you so much. this is seriously the best community.

edit: i used your last suggested code.

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: i just want a toggle button (i've searched)

Post by thecon »

Following up on this thread, I want to do a similar thing, a bit simpler though.

I just want a button to toggle between SortFoldersApart setting. Without toggling the List/Thumbnail view.

This is how far I've come:


$View = get("View");
if (<get trigger> == 1) {
if (ctbicon() != ":viewlist" AND $View != 2) {
ctbicon(":favfiles");
ctbstate(0);
Settingp "SortFoldersApart",1;
#304; // go to List view
} else { // if list go to Thumbnail view
ctbicon(":favs");
ctbstate(1);
Settingp "SortFoldersApart",0;
#307;
}
end 1;
}

if (<get trigger> == 2) {
button "views", 2;
end 1;
}


I cannot seem to be able to get rid of the List/Thumbnail View part of the code without messing it up.

Any help?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: i just want a toggle button (i've searched)

Post by highend »

Code: Select all

if (get("#333")) {
        ctbstate(0);
        settingp "SortFoldersApart", 0;
    } else {
        ctbstate(1);
        settingp "SortFoldersApart", 1;
    }
One of my scripts helped you out? Please donate via Paypal

thecon
Posts: 52
Joined: 09 Nov 2015 19:08

Re: i just want a toggle button (i've searched)

Post by thecon »

That was great! Thanks. I also added ctbicon rules to have a visual indicator as well. See here:

Code: Select all

if (get("#333")) {
        ctbstate(0);
        settingp "SortFoldersApart", 0;
        ctbicon(":favs");
    } else {
        ctbstate(1);
        settingp "SortFoldersApart", 1;
        ctbicon(":favfiles");
    }

Post Reply