Page 1 of 1

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

Posted: 28 Mar 2017 02:54
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

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

Posted: 28 Mar 2017 08:01
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

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

Posted: 28 Mar 2017 08:08
by bdeshi
Or use ctbstate().
Set/Get the pressed state of a Custom Toolbar Button (CTB).

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

Posted: 28 Mar 2017 11:21
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!

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

Posted: 28 Mar 2017 13:45
by cadu
It worked. Thanks!

Code: Select all

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