FORUMS: list search recent posts

dropdown interaction issue...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Fabio Apelbaum
dropdown interaction issue...
on May 13, 2016 at 7:32:32 pm

Hi guys,

I have a composition with 48 layers, and I decided to separate them all in groups of 12 layers depending on its properties (with or without logo or bar)... See image attached.



Anyways, the dropdowns works good, when I select an item of one of the dropdowns, it makes that one layer visible and disable all the other layers...

Where I am having problems is, I want my user interface to only show the selected layer within the dropdown and have the other three dropdowns show blank or dd.selection=0.

So I added to each dropdown the following:

//SELECT DROPDOWN A
ddA.onChange = function() {
ddB.selection = 0; //I also tried changing 0 for null; and same problem.
ddC.selection = 0;
ddD.selection = 0;

Additional code...
};
//SELECT DROPDOWN B
ddB.onChange = function() {
ddA.selection = 0; //I also tried changing 0 for null; and same problem.
ddC.selection = 0;
ddD.selection = 0;

Additional code...
};

//SELECT DROPDOWN C
ddC.onChange = function() {
ddA.selection = 0; //I also tried changing 0 for null; and same problem.
ddB.selection = 0;
ddD.selection = 0;

Additional code...
};

//SELECT DROPDOWN D
ddD.onChange = function() {
ddA.selection = 0; //I also tried changing 0 for null; and same problem.
ddB.selection = 0;
ddC.selection = 0;

Additional code...
};


The problem is that it is not just changing the selection on my GUI, but is triggering the other three dropdowns .onChange event, even if I am not using notify() which causes the dropdowns to conflict between all of them. Is there a way to tell it that when the user selects one option from one of the dropdowns to make the other dropdown to show the first item on their list which is " " without triggering the .onChange of the additional dropdowns?

Thanks in advance for the help!

Fabio


Return to posts index

Xavier Gomez
Re: dropdown interaction issue...
on May 13, 2016 at 8:09:08 pm

To set a dropdown selection without triggering its onChange event, you can temporarily either delete the onChange handler (javascript delete), or assign to it the undefined value, or assign to it a dummy onChange that does nothing.
For instance, this would work i think (set dummy onChange):

var dds = [ddA, ddB, ddC, ddD];
for (var i=0; i<4; i++) dds[i].onChange = onDDchange;

function noop(){};
function onDDChange(){
for (var i=0; i<4; i++){
if (dds[i] == this){
// stuff to do for the dropdown which is been changed
/*your stuff*/
}
else if (dds[i].selection !== null){
// stuff to do for other dds : reset selection to null
dds[i].onChange = noop;
dds[i].selection = null;
dds[i].onChange = onDDChange;
};
};
};


Replacing the line dds[i].onChange = noop; by
dds[i].onChange = void 0;
or by:
delete dds[i].onChange;
would work too.

However i dont know a direct way to set a dd's selection without triggering.

Xavier


Return to posts index

Fabio Apelbaum
Re: dropdown interaction issue...
on May 16, 2016 at 3:28:58 pm

Xavier! thank you so much, it works great!

Let me ask you a question to better understand whats going on,

when I read:

var dds = [ddA, ddB, ddC, ddD];
for (var i=0; i<4; i++) dds[i].onChange = onDDChange;


why is that onDDChange not using parentheses? onDDChange() if it is related to the function?

Thanks again!!

Fabio


Return to posts index


Xavier Gomez
Re: dropdown interaction issue...
on May 16, 2016 at 4:00:16 pm

onDDchange is the function itself, while onDDchange() is its result (which is undefined since the function returns nothing).
You want to assign the function, not its result.

After i answered you i came across this article:
http://www.davidebarranca.com/2013/09/scriptui-tip-decoupling-components-ev....
It might interest you. As far as i'm concerned, bubbling or no bubbling gives me headaches, i actually use code similar to the one in my answer and i'm fine with it.

Xavier


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]