Enabl button on selection only
Enabl button on selection only
Just like open with toolbar button, how can I have a custom button enabled only when items are selected?
Thanks
Thanks
Re: Enabl button on selection only
Scripted buttons cannot update themselves automatically. Sorry.
----
the ctbstate() function sets/gets buttons state.
----
the ctbstate() function sets/gets buttons state.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Enabl button on selection only
Thanks for the reply SammaySarkar.
Is it possible to have a balloon tip? Easier to dismiss than a msg.
Is it possible to have a balloon tip? Easier to dismiss than a msg.
Re: Enabl button on selection only
Can you be more specific about what you want to do?
Here's a demo button script. Set as the LClick script of a button.
The button's hover tooltip changes depending on current selection.
If you select some files and click the button, it's tooltip says " something selected". Otherwise it says "nothing selected".Remember, you still do need to click the button to update the tooltip!
BTW, I'm sure you know it's also possible to construct a button script in a way that it executes only if some items are selected, eliminating the need to disable/enable the button.
Here's a demo button script. Set as the LClick script of a button.
The button's hover tooltip changes depending on current selection.
If you select some files and click the button, it's tooltip says " something selected". Otherwise it says "nothing selected".
Code: Select all
if (get(selectedItemsNames) == "") {ctbname("nothing selected")} else {ctbname("something selected")}BTW, I'm sure you know it's also possible to construct a button script in a way that it executes only if some items are selected, eliminating the need to disable/enable the button.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Enabl button on selection only
Actually I just started scripting in XYplorer, its very useful.
At the moment I'm checking on top of my script to see if something is selected or not, like this...
But that requires one more click to get rid of the msg, I tried the status bar, not obvious enough.
That's why I asked about the balloon tip, they are customizable, icon, title, sub text and timer, and clicking it or anywhere else will dismiss it.
Your example is using a tooltip.
At the moment I'm checking on top of my script to see if something is selected or not, like this...
Code: Select all
end ($p_selCount == 0), "Nothing selected in the file list.";That's why I asked about the balloon tip, they are customizable, icon, title, sub text and timer, and clicking it or anywhere else will dismiss it.
Your example is using a tooltip.
Re: Enabl button on selection only
Balloon tips aren't supported you'd need an external tool to display them...
One of my scripts helped you out? Please donate via Paypal
-
klownboy
- Posts: 4397
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Enabl button on selection only
Like both Sammay and highend stated tooltips are not supported but you can as Sammy mentioned use CTBname and also use CTBstate and CTBicon to indicated different states. Just as an example, try this code. Type ::snippet; in the AB and then past the following snippet in the box.
Code: Select all
Snip: CTB 1
XYplorer 14.40.0304, 9/6/2014 11:17:16 AM
Action
NewUserButton
Name
Please select files first
Icon
:nuke
ScriptL
$file_sel = get(selecteditemspathnames, "<crlf>");
if($file_sel != "") {
ctbstate(1,);
ctbname("Files selected",);
ctbicon("label: yes >554433,ffffee",); //use any icon you'd like here
echo $file_sel; // you could do whatever you'd like to the selected files
}
else {ctbstate(0,);
ctbicon("label: No >554433,ffffee",); //use any icon you'd like here to reflect a different state
ctbname("No files selected",);
echo "No files selected."; // you could prompt user via na SC input to select files
ctbname("Please select files first",);
}
ctbicon(:nuke,);
ctbname("Please select files first",);
ctbstate(0,);
ScriptR
FireClick
0Re: Enabl button on selection only
winapiexec should fit the bill nicely...highend wrote:Balloon tips aren't supported you'd need an external tool to display them.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Enabl button on selection only
You can try with popupmenu, showing the wanted text, and executing just "End 1;"
Next Stmt "End 1;", too.
If you click the text, the 'menu' vanishes.
If you click outside: it vanishes too.
Next Stmt "End 1;", too.
If you click the text, the 'menu' vanishes.
If you click outside: it vanishes too.
Re: Enabl button on selection only
Thanks for the help guys 
popupmenu is the best solution for now, is it possible to add an icon to it?
popupmenu is the best solution for now, is it possible to add an icon to it?
-
klownboy
- Posts: 4397
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Enabl button on selection only
Not that I'm aware of...popupmenu has no icon options.U_2582 wrote: is it possible to add an icon to it?
Re: Enabl button on selection only
You can try this:
use a valid icon path.
Code: Select all
if ($p_selCount == 0/*1:typo*/){
load <<<#>>>>
"Nothing selected in filelist|<xyicons>\scheme\crosss.ico" end 1;<crlf>""#>>>>,,s; end 1;
}Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
klownboy
- Posts: 4397
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Enabl button on selection only
Very clever Sammay.
In this case so as to match the statement, shouldn't $p_selCount = "" not "1", if you're using something like $p_selCount = get("selectedItemsNames");
Re: Enabl button on selection only
Nice SammaySarkar, only glitch is that I'm getting an extra separator in the popupmenu.
Also can I define icon size for the popupmenu? 24, 32 etc
Also can I define icon size for the popupmenu? 24, 32 etc
Re: Enabl button on selection only
Thanks, Ken!
Thanks, Ken, that would be a devastatypo.
I edited the script to match the snippet U_2 had posted, but missed the if.
U_2, the separator is a necessaryevil dummy.
Otherwise the menu has a single member, it's selected automatically, and the menu isn't displayed at all. Which defeats the main purpose here.
Also you can't resize those icons.
Thanks, Ken, that would be a devastatypo.
U_2, the separator is a necessary
Otherwise the menu has a single member, it's selected automatically, and the menu isn't displayed at all. Which defeats the main purpose here.
Also you can't resize those icons.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
XYplorer Beta Club