Page 1 of 1

Disabling a button or Hiding a Custom Script Button

PostPosted: Tue Jan 19, 2016 6:54 pm
by crotkosky
I've come across a task where in the client needs to have access to a Widget panel.

There are a couple of buttons I'd like to have disabled unless some layers are active to screen. I tried the WDCustomScriptMuteClick Command via a NODE set up PBDeviceParameter - Script output IF - THEN statement. This I could not get to work successfully. I did find by reading through posts, that another user was encouraged to use the ControlShow / ControlHide solution. This works great, and solves my problem but does not look very nice, as buttons are appearing and disappearing. I also read this following post, (link below) a script used to disable a button with IF THEN statements. I dont think though this is exactly what I am looking for.

viewtopic.php?f=80&t=3714&p=11330&hilit=Mute#p11330

Have a great week everyone!! Thanks in advance for any input.
Best,
Chris

Re: Disabling a button or Hiding a Custom Script Button

PostPosted: Wed Jan 20, 2016 12:43 am
by malkuth23
I would probably do the if/then method.
Why would that not work for your code? Are you tracking a ton of layers?

Re: Disabling a button or Hiding a Custom Script Button

PostPosted: Wed Jan 20, 2016 1:29 am
by crotkosky
Unfortunately I do not have a lot of experience with writing the code aspect of this yet. So as I understand the concept of the if - then statements and = to etc. I do not know how to figure them into / or where to put them in the script boxes... :) these are the things I'm learning as I go. Thanks!!! I'll task myself to learn this.

Best,
Chris

Re: Disabling a button or Hiding a Custom Script Button

PostPosted: Wed Jan 20, 2016 5:23 am
by malkuth23
So here is the basic idea:

Each layer should be represented by a variable.

Create each variable where 0=not visible and 1=visible. This can alternatively be done in the variable tool. Use integer.
Code: Select all
layer1Vis = 0
layer2Vis = 0


Then in each button use code like this:
Code: Select all
if layer1Vis = 1
{
//do some cool stuff
}


Adjust the variables by using a node to check the pb layer opacity (or whatever parameter is relevant) and output to a variable node.

Re: Disabling a button or Hiding a Custom Script Button

PostPosted: Fri Jan 29, 2016 11:11 pm
by chrisr
Matthew,
Thanks for the head start with this information.

Cheers,

Re: Disabling a button or Hiding a Custom Script Button

PostPosted: Thu Apr 14, 2016 5:45 pm
by chrisr
Matthew-

Totally forgot to reply to this. That worked fantastic, thank you very much!

my Lock button wrote a variable UnLocked = 1, Locked = 0

So the Script looked like

If LockVar = 1
{
Do cool stuff
}