Page 1 of 1
i just want a toggle button (i've searched)
Posted: 29 Sep 2017 13:42
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?
Re: i just want a toggle button (i've searched)
Posted: 29 Sep 2017 13:50
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.
Re: i just want a toggle button (i've searched)
Posted: 30 Sep 2017 00:33
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?
Re: i just want a toggle button (i've searched)
Posted: 30 Sep 2017 03:09
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.
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.
Re: i just want a toggle button (i've searched)
Posted: 30 Sep 2017 20:08
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.
Re: i just want a toggle button (i've searched)
Posted: 01 Oct 2017 09:45
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.
Re: i just want a toggle button (i've searched)
Posted: 15 Feb 2023 08:13
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?
Re: i just want a toggle button (i've searched)
Posted: 15 Feb 2023 08:26
by highend
Code: Select all
if (get("#333")) {
ctbstate(0);
settingp "SortFoldersApart", 0;
} else {
ctbstate(1);
settingp "SortFoldersApart", 1;
}
Re: i just want a toggle button (i've searched)
Posted: 15 Feb 2023 09:09
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");
}