User Button: After clicking, possible the button state be showed as activated?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
cadu
Posts: 287
Joined: 18 Mar 2012 21:50

User Button: After clicking, possible the button state be showed as activated?

Post by cadu »

Hi,

I'm testing user buttons with commands that have a state (activated/deactivated).
For instance, I added in a custom button a simple command #668 (show tree) as showed in this snapshot: http://i.imgur.com/1yurWcK.png
However, when I click on the button, although the command is activated, the button state doesn't change.
In comparison, the default XYplorer button to show tree, when pressed, changes the state to activated (the button becomes hollow).
How to set the user button to show the current state (activated it becomes hollow / deactivated it is showed normal, shallow, without visual identification)?

Thanks for info!
Cadu

highend
Posts: 15000
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: User Button: After clicking, possible the button state be showed as activated?

Post by highend »

You can assign any icon to a user defined button so you need to script it
E.g. save the current setting in a permanent variable, and depending on
it's state, change the icon with it
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: User Button: After clicking, possible the button state be showed as activated?

Post by bdeshi »

Or use ctbstate().
Set/Get the pressed state of a Custom Toolbar Button (CTB).
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: User Button: After clicking, possible the button state be showed as activated?

Post by PeterH »

You describe a way helping a bit to set the button to the correct state.

But: I have the same for "Toggle Active Pane". I *can* show the correct button state when executing a script that changes it. Now when you change the active pane by other means (e.g. by clicking into a pane) my script isn't active and can't see it - so the button state is wrong until my script regains control again to change it.

So, for user buttons it should be possible to display a kind of "generic" icon for a button, that's automatically changed by XY when the "monitored" state changes. So: insterad of icons :dp1 and :dp2 just specify :dp, and XY remembers this as "automatic icon" and automatically changes it when the state changes. (As system-buttons show this is possible - but currently not for user buttons.)

Edited to note: this is a wish!

cadu
Posts: 287
Joined: 18 Mar 2012 21:50

Re: User Button: After clicking, possible the button state be showed as activated?

Post by cadu »

It worked. Thanks!

Code: Select all

Toggle Button State
          if (ctbstate() == 1) {
            ctbstate(0);
          } else {
            ctbstate(1);
          }

Post Reply